batch file giving error while execution that \F was expected

July 17, 2017 at 01:15:17
Specs: Windows 7
below is the code

@echo off


set counter=0
set SCRIPTFOLDER=D:\patchcopy
For /F "tokens=1,2 delims=," %%G IN (plist.txt) DO (
echo branch ID :%%H
set username= KKKK%%Hsvr1\bsc%%Husr
set password=TTTT
net use t: \\%%G\c$ /User:KKKK%%Hsvr1\bsc%%Husr TTTT

%SCRIPTFOLDER%\psexec.EXE -accepteula \\%%G -u bsc%%Husr -p Ibs#csb2K cmd.exe /c "FOR /F"usebackq=*"%r%r in(' cscript.exe /nologo "c:\Users\06172adm\Desktop\san.vbs" ') DO SET Result=%r%r"
echo %Result%

net use t: /delete
set /a counter=counter+1
)


See More: batch file giving error while execution that \F was expected

Reply ↓  Report •

#1
July 17, 2017 at 20:10:08
starts here (trouble):
cmd.exe /c "FOR /F"usebackq=*"%r%r in(' cscript.exe /nologo "c:\Users\06172adm\Desktop\san.vbs" ') DO SET Result=%r%r"

this is quite a hash. The quotes have gone feral and syntax off the rails.
My understanding you simply want to capture output from san.vbs on a remote system.(?) I'm not familiar with psexec, so the cmd.exe may be required to execute your intent. Also, I don't know what the output of san.vbs looks like.
The "usebackq=*" is wrong: "usebackq" does not have any modifiers or arguments that I know of.
Embedding of dbl-quotes is tricky at best, and usually not a good idea.
The variable %r%r will not fly as a batch-level variable. It must be like %%r and no following letter.
All the quotes is the main thing that's got you messed up. Sorry I can't answer more at this point. posting output of san.vbs would help us all


Reply ↓  Report •

#2
July 21, 2017 at 12:29:09
%SCRIPTFOLDER%\psexec.EXE -accepteula \\%%G -u bsc%%Husr -p Ibs#csb2K cmd.exe /c "FOR /F"usebackq=*"%r%r in(' cscript.exe /nologo "c:\Users\06172adm\Desktop\san.vbs" ') DO SET Result=%r%r"
echo %Result%
Not entirely sure what you're going for here, but I suspect you're looking for something closer to:
%SCRIPTFOLDER%\psexec.EXE -accepteula \\%%G -u bsc%%Husr -p Ibs#csb2K cscript.exe /nologo "c:\Users\06172adm\Desktop\san.vbs"

How To Ask Questions The Smart Way

message edited by Razor2.3


Reply ↓  Report •
Related Solutions


Ask Question