Suk said:
Is there any way in Perl I can open a port on a remote WinXP PC and
find out who is currently logged in to that PC?
If the local computer also runs Windows, the easiest way is through
a WMI (Windows Management Instrumentarium) query.
Is anyone aware of
any modules which could assist in this query?
Win32::OLE
Sofwtare such as
LANguard tells you who is logged on to a remote PC but I dont know how
it does this.
Most admin tools also utilize the WMI query interface. OS Versions
from NT4 SP4 upward support it.
Here's a little script that does that. If you want further information,
have a look at Microsoft's WMI Reference athttp://msdn2.microsoft.com/en-us/library/aa394572.aspx
which lists all available classes and properties.
------------------------------------------------------------------------
#!/usr/bin/perl
use strict;
use warnings;
use Win32::OLE qw(in);
my $computer = $ARGV[0] || "."; # Either from command line or localhost
my $oWMIService = Win32::OLE->GetObject(
"winmgmts:\\\\$computer\\root\\CIMV2"
)
or die "WMI connection failed.\n";
my $collComputers = $oWMIService->ExecQuery(
"SELECT * FROM Win32_ComputerSystem"
);
foreach my $comp ( in( $collComputers ) ) {
print "Computer: " . $comp->{"Name"} . $/;
print "User: " . $comp->{"UserName"},$/;}
__END__