Re: Retrieve a list of logged-in users

From: Sam Hobbs (samuel_at_social.rr.com_change_social_to_socal)
Date: 03/15/05

  • Next message: Sam Hobbs: "Re: Retrieve a list of logged-in users"
    Date: Tue, 15 Mar 2005 08:58:30 -0800
    
    

    The following works in XP but for me the Name, Caption and Description
    properties are null. The LogonType though is valid and might help. Perhaps
    it is possible to get the account name for each specific LogonId. Note that
    this uses WMI.

    Pathname = "winmgmts:{impersonationLevel=impersonate}!//./root/cimv2"
    Query = "SELECT * FROM Win32_LogonSession"
    Set LogonSessions = GetObject(Pathname).ExecQuery(Query)
    Message = ""
    For Each LogonSession In LogonSessions
        Message = vbCrLf & Message & LogonSession.LogonId
    Next
    WScript.Echo Mid(Message, 2)

    "Grant Robinson" <grantsky4u@community.nospam> wrote in message
    news:uPJyT6PKFHA.484@TK2MSFTNGP15.phx.gbl...
    >I believe this is the correct newsgroup for this type of question, but if
    >it
    > should be asked elsewhere, please let me know.
    >
    > I am attempting to retrieve a list of users who are logged in. For
    > starters, I would like a list of people logged in at the console
    > (including
    > Fast User Switching people) and, if it's not too much more code, also
    > those
    > who are logged in under terminal services. I have been unable to find any
    > sort of real documentation on how to do this. Could someone please point
    > me
    > in the right direction (via documentation, a how-to, or sample code)?
    > Even
    > a list of API calls to play around with would be helpful at this point.
    >
    > Thanks in advance,
    >
    > Grant Robinson
    > grantsky4u@community.nospam
    >
    >


  • Next message: Sam Hobbs: "Re: Retrieve a list of logged-in users"