PSEXEC redirect output to local file

a 夏天 提交于 2019-12-08 05:57:55

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!