Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

ID of windows sessions

22 views
Skip to first unread message

Petr Laznovsky

unread,
May 26, 2016, 4:51:04 PM5/26/16
to
On startup machine running Windows 7 need to start GUI application in single session (let`s call it
Console session) of specific user (on which credentials is preformed autologon). Need to prevent the
GUI application start if someone create another session for autologon user or any other user session
create. Also need to periodically check if GUI app still running under proper session and account.

Before script creating, trying to discover SessionID but different methods results differ:

Console session have ID 4

--------------------------------------------------------------------------
c:\>qwinsta
SESSIONNAME USERNAME ID STATE TYPE DEVICE
>rdp-tcp#13961 USER1 0 Active rdpwd
rdp-tcp 65536 Listen rdpwd
rdp-tcp#14263 USER2 1 Active rdpwd
console 4 Conn wdcon
--------------------------------------------------------------------------


app.exe started on startup in console session have ID 0

---------------------------------------------------------------------------
c:\>tasklist /FI "imagename eq app.exe"

Image Name PID Session Name Session# Mem Usage
========================= ======== ================ =========== ============
app.exe 28952 RDP-Tcp#13961 0 23 776 K
---------------------------------------------------------------------------

Successfully listing 'app.exe' on session ID 0 by WMI

---------------------------------------------------------------------------
c:\>getwmiproperty.exe -class Win32_Process -property Name -filter "SessionID ='0'" | findstr /i /C:app
app
---------------------------------------------------------------------------

Utility SessionID.exe started on console session (overtaken by RDP session) have ID 4

---------------------------------------------------------------------------
c:\>sessionid
4
---------------------------------------------------------------------------


Could someone clarify how windows assing ID to sessions?

L.

JJ

unread,
May 28, 2016, 10:32:51 AM5/28/16
to
How exactly did the app.exe assigned to a session?

Petr Laznovsky

unread,
May 29, 2016, 5:51:01 AM5/29/16
to
Dne 28.5.2016 v 16:32 JJ napsal(a):
app.exe is started by task scheduler (on machine startup)

L.
0 new messages