How can I retrieve the current user session ID via windows command line?
feedback
|
|
This is certainly not the most efficient way, but you can take a look at 'tasklist'. It will display the name and session# of each process running. If you are logged in locally then look at the ID for the session named "console". Edit | |||||||||||
feedback
|
|
Unlike the Session Name, the Session ID is not stored in a variable and is not as easy to get to. I am sure there is one, but I can't think of a built in command line tool that does this. However, I have written a tiny .exe file (C#, .Net 4) that does this. It will both display the session id, and also have it as the return code so that you can use this in a variety of scripts/techniques. | |||||
|
feedback
|