PsExec run remote batch file in visible mode

不羁岁月 提交于 2019-12-01 11:23:10

问题


I am trying to execute following command

psexec \\x.x.x.x -d -c -f cmd.exe /c d:\test\hello.bat

It runs fine and gives output

cmd.exe started on x.x.x.x with process ID 106084.

But when I login on x.x.x.x I can find the process ID but no visible batch file is launched. It runs in background.

Batch file

echo "Hello"
pause

Please tell me how to see the command window launched on x.x.x.x

Thanks in advance


回答1:


Alex K. is correct. Specifically, remove the "-d", which tells PsExec "Don't wait for process to terminate (non-interactive)". In fact, if you run the sample batch file above, which includes "pause", the cmd process will continue to run on the remote host (invisible to the remote host's GUI, since it's done via PSExec) until you kill that process.




回答2:


I think you can look at the Session Id for your current user and pass it as parameter with -i For example:

PsExec.exe -s -d -i 2 c:\temp\MyServer MyConsoleApp.exe

To look at the current Session Id you can run query session

Sometimes the Session Id is 2 for the active user you want to start process for, so try looking for your correct Session Id and use it with -i parameter.




回答3:


Try one of those:

  1. psexec \\server -u xxx-p xxxx /accepteula  -i 1 -d cmd.exe /K "cd d:\test && call hello.bat"
    
  2. psexec \\server -u xxx -p xxxx /accepteula  -i 1 -d d:\test\hello.bat
    


来源:https://stackoverflow.com/questions/9566862/psexec-run-remote-batch-file-in-visible-mode

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