Session ID in PSExec

前端 未结 2 1887
既然无缘
既然无缘 2021-01-14 03:57

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>         


        
相关标签:
2条回答
  • 2021-01-14 04:28

    To get session ID I use this batch (sorry it's on a french server) :

    C:\Windows\system32>psexec -nobanner \\FRBBL31101 query session
    
     SESSION           UTILISATEUR              ID  ÉTAT    TYPE        PÉRIPHÉRIQUE
    >services                                    0  Déco
     console           toto                      1  Actif
    query exited on FRBBL31101 with error code 1.
    

    What we want is the id (the third tokens) at the line containing the word 'console'

    my batch :

    rem Enter batch name with computer name after like : MyBatch.cmd Mycomputer
    set host=%1
    FOR /F "tokens=3 delims= " %%i IN ('psexec -nobanner \\%host% query session ^| findstr "console"') DO set "ID=%%i"
    
    0 讨论(0)
  • 2021-01-14 04:35

    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.

    0 讨论(0)
提交回复
热议问题