Hi Patrick,

I tried using the following snippet
of code in my script to determine
who's logged on to there machine:

if ( Win32::Lanman::NetWkstaGetInfo( $Machine, \%Info, $bExtendedInfo ) ) {
                print " $Info{computername} \n";
            print " $Info{logged_on_users} \n";
            }

my manager wants me to go this way instead of sending a logoff message.
But I am getting more than one user logged on to one machine, 
which it should be showing only one user logged on.
Would you know why?

thanks,

John

-----Original Message-----
From: Patrick J. LoPresti [mailto:[EMAIL PROTECTED]
Sent: Saturday, March 08, 2003 7:37 AM
To: John Deretich
Cc: Perl-Win32-Admin-Request (E-mail)
Subject: Re: signoff message


John Deretich <[EMAIL PROTECTED]> writes:

> I was wondering if there's a win32 module that can tell if a user is
> logged on to there machine?

Hm, this appears harder than one might expect.

You can use WMI.  Enumerate all instances of the Win32_LoggedOnUser
class to obtain mappings between accounts and logon sessions, then
check the LogonType field of each session to find the one (if any)
which is interactive.

Documentation for the classes are here:

  http://msdn.microsoft.com/library/en-us/wmisdk/wmi/win32_loggedonuser.asp

  http://msdn.microsoft.com/library/en-us/wmisdk/wmi/win32_logonsession.asp

The catch is that these were introduced with Windows XP, so this will
not work on earlier versions of Windows.  If that is OK for you, and
if nobody else has any better ideas, let me know and I will flesh out
this approach into actual code.

 - Pat
_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to