PSExec 2.4: option -i does not start process in console session

allan_g 21 Reputation points
2022-10-17T10:23:47.397+00:00

PSExec says the following about option -i: "If no session is specified the process runs in the console session."

This used to work way back in version 2.11, but with recent releases the process is started in the services session (ID 0). Is there any fix or work-around? I need to run PSExec from a batch file and cannot determine the session ID manually.

Sysinternals
Sysinternals
Advanced system utilities to manage, troubleshoot, and diagnose Windows and Linux systems and applications.
1,103 questions
0 comments No comments
{count} votes

Accepted answer
  1. MotoX80 32,326 Reputation points
    2022-10-18T18:27:29.28+00:00

    I have 2.2 and 2.4 and can recreate the behaviour.

    You could run quser and parse the output to get the session id.

    C:\Temp\test>psexec \\test10  -u admin -p admin quser.exe  
      
    PsExec v2.4 - Execute processes remotely  
    Copyright (C) 2001-2022 Mark Russinovich  
    Sysinternals - www.sysinternals.com  
      
      
     USERNAME              SESSIONNAME        ID  STATE   IDLE TIME  LOGON TIME  
     admin                                     1  Disc            1  10/11/2022 7:54 AM  
     testuser              console             2  Active      none   10/18/2022 2:23 PM  
    quser.exe exited on test10 with error code 0.  
    

0 additional answers

Sort by: Most helpful