问题
I need the correct way to accomplish this via a vbscript.
This works fine from command prompt:
psexec \\99.99.99.99 -u username -p password cmd.exe /c ver > output.txt
From the vbscript:
sTempFile = objFSO.GetTempName
sCmd = "psexec \\" & sIP & " -u " & sDomain & "\" & sUser & " -p " & sPassword & " cmd /c ver > " & sTempFile
WSHShell.Run sCmd, 1, True
I always get a runtime error: File not found
Thanks, Sam
回答1:
Dont know why but adding cmd /c also before psexec did the trick.
回答2:
Use the syntax below : cmd /c ver 2>output.txt
and you are done!
If you want to append the output file
cmd /c ver 2>>output.txt
来源:https://stackoverflow.com/questions/1399191/psexec-redirect-output-to-local-file