Session ID in PSExec

12,896

If you are just trying to run notepad on the remote machine do the following:

psexec \\135.20.230.160 -u administrator -p force C:\notepad.exe

More info on psexec

Also I am assuming your password is "force" and as a side note you should not put your password online...

If you want to see notepad.exe open on the machine you are connecting to, for example if you are remote connected into that machine while using psexec from another you would use the following

psexec \\135.20.230.160 -u administrator -p force -i 1 C:\notepad.exe

The 1 after the -i is the session number which needs to correspond to the session which you are logged in as.

To find out what session you are currently logged in as open any program and in console type TaskList and find your program and look at the session number.

Share:
12,896
user3565150
Author by

user3565150

Updated on June 28, 2022

Comments

  • user3565150
    user3565150 almost 2 years

    Psexec fails to display a notepad GUI on the remote session for me. So, I am trying to get the session id as below:

    c:\Users\Amitra\Downloads\PSTools>PsExec -u administrator -p force \\135.20.230.160 query session
    PsExec v2.11 - Execute processes remotely
    Copyright (C) 2001-2014 Mark Russinovich
    Sysinternals - www.sysinternals.com
     SESSIONNAME       USERNAME                 ID  STATE   TYPE        DEVICE
    >services                                    0  Disc
     rdp-tcp#0         Administrator             1  Active  rdpwd
     console                                     4  Conn
     rdp-tcp                                 65536  Listen
    query exited on 135.20.230.160 with error code 1.
    

    Now, with the above output, what should be the correct command in psexec to run notepad on the IP address?