Showing who is logged on to XP

S

Suk

Hi

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? Is anyone aware of
any modules which could assist in this query? Sofwtare such as
LANguard tells you who is logged on to a remote PC but I dont know how
it does this.
 
P

Peter Wyzl

Suk said:
Hi

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? Is anyone aware of
any modules which could assist in this query? Sofwtare such as
LANguard tells you who is logged on to a remote PC but I dont know how
it does this.

analysing the result of nbtstat would be one way...

P
 
S

Suk

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__


Thanks for your answer. Unfortunately the localhost is running Solaris
with Perl 5.8.5 Is there anyway I could connect to the WMI port and
get the information I need?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,787
Messages
2,569,629
Members
45,330
Latest member
AlvaStingl

Latest Threads

Top