Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PsExec run remote batch file in visible mode

Tags:

psexec

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

like image 249
Rohit Avatar asked Mar 11 '26 23:03

Rohit


2 Answers

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.

like image 191
Dipti Chaudhry Avatar answered Mar 17 '26 05:03

Dipti Chaudhry


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
    
like image 40
Venkat Keesara Avatar answered Mar 17 '26 03:03

Venkat Keesara



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!