PsExec run remote batch file in visible mode

前端 未结 4 773
忘掉有多难
忘掉有多难 2021-01-16 12:57

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



        
相关标签:
4条回答
  • 2021-01-16 13:26

    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.

    0 讨论(0)
  • 2021-01-16 13:26
    PsExec.exe -s -i 2 C:\path_to_exe.exe
    

    This need to check with the session ID variable (-s & -i)

    0 讨论(0)
  • 2021-01-16 13:29

    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.

    0 讨论(0)
  • 2021-01-16 13:34

    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
      
    0 讨论(0)
提交回复
热议问题