You mentioned Win32::OLE but also mention "WMI" in your title. If you're using an external program, how about 'query':

VinsWorldcom@C:\Users\VinsWorldcom> which query C:\Windows\system32\query.exe VinsWorldcom@C:\Users\VinsWorldcom> query /? QUERY { PROCESS | SESSION | TERMSERVER | USER } VinsWorldcom@C:\Users\VinsWorldcom> query user /? Display information about users logged on to the system. QUERY USER [username | sessionname | sessionid] [/SERVER:servername] username Identifies the username. sessionname Identifies the session named sessionname. sessionid Identifies the session with ID sessionid. /SERVER:servername The server to be queried (default is current). VinsWorldcom@C:\Users\VinsWorldcom> query user USERNAME SESSIONNAME ID STATE IDLE TIME LOGON + TIME >VinsWorldcom console 1 Active none 5/21/ +2013 7:03 PM

Not sure if the 'query' command functionality is in Win32::OLE.

Also note that the command 'net user USERNAME' returns the last logon time, but it is reset even if the user locks the screen and then unlocks it.


In reply to Re: Query current logged in Windows user via WMI by VinsWorldcom
in thread Query current logged in Windows user via WMI by wveagle81

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.