6

I am trying to use PSExec to kick off a console application on a remote computer in an interactive state. When I run something like this:

PsExec.exe -s -d -i 1 \\MyServer notepad.exe

It launches Notepad just fine. If I then run this:

PsExec.exe -s -d -i 1 \\MyServer C:\Temp\MyConsoleApp.exe

It launches the command windows but doesn't do anything as far as I can tell. As in, when I run my console application locally, it displays a "heartbeat" every 5 seconds, but when I run it remotely, nothing is displayed in the command window. The .exe does show up as a process in Task Manager. Any ideas?

4 Answers 4

4

i think you have to set the working directory with -w :

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

http://technet.microsoft.com/en-us/sysinternals/bb897553.aspx

0
5

If no window appears, it is likely because the session id in the invocation of psexec is wrong.

This is set as the number after the -d flag.

The id number you want will appear in the 'ID' column of the list on the Users tab of taskmgr.exe It's usually 1, but might not be. And ommitting the number can also cause no window to appear.

eg, I ran:

psexec -i -d -s c:\windows\regedit.exe

(as advised elsewhere) and although I got a message: "... regedit.exe started on ... with process ID ...", no window appeared, even though I could see in taskmgr.exe that it was running with the indicated process ID.

However, when I ran:

psexec -s -d -i 1 regedit.exe

The window did appear. It so happened that my ID was 1.

1
  • Thx a lot! I've been searching for this comment for hours!
    – matebende
    Aug 26, 2021 at 12:30
1

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** -w c:\temp \\MyServer MyConsoleApp.exe

To look at the correct session Id you can open cmd and run command : 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 patameter. It should work. It worked for me.

2
  • How do I look for a session ID? Sep 4, 2015 at 9:02
  • @ThomasWeller quser
    – totaam
    Apr 5, 2020 at 14:18
-2

To look for a session ID of a User, open Task manager on that particular computer and look for your logged in username on Users Tab.

1
  • This doesn't appear to address the question. Jan 5, 2016 at 14:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .