2

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

Rohit
  • 353
  • 2
  • 8
  • 24
  • 1
    Look at the command line switches, there is one for interactive mode. – Alex K. Mar 05 '12 at 12:48
  • I did add -i switch but if I issue command from machine A for machine B then machine A stops for execution on machine B to complete but when I log in on machine B I can only see the process ID from task manager but no visible cmd window. – Rohit Mar 06 '12 at 03:26

4 Answers4

4

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.

henrycarteruk
  • 12,708
  • 2
  • 36
  • 40
2

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
    
Philip Allgaier
  • 3,505
  • 2
  • 26
  • 53
  • Hi Philip, can you please check this I am not able to launch GUI as you said above. http://stackoverflow.com/questions/24203577/launch-notepad-exe-using-psexec-sysinternal-tool – Sam Jun 13 '14 at 11:07
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.

Lizz
  • 1,442
  • 5
  • 25
  • 51
0
PsExec.exe -s -i 2 C:\path_to_exe.exe

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

user3636989
  • 161
  • 1
  • 9