The need arose, in our product, to determine how long the current user has been logged on to Windows (specifically, Vista). It seems there is no straight forward API function for this and I couldn’t find anything relevant with WMI (although I’m no expert with WMI, so I might have missed something).
Any ideas?
For people not familiar with WMI (like me), here are some links:
And here’s example querying Win32_Session from VBS:
It alerts 6 sessions for my personal computer, perhaps you can filter by LogonType to only list the real (‘interactive’) users. I couldn’t see how you can select the session of the ‘current user’.
[edit] and here’s a result from Google to your problem: http://forum.sysinternals.com/forum_posts.asp?TID=3755