-----Original Message-----
From: Royer, Robby E (Compaq) [mailto:[EMAIL PROTECTED]]
Sent: Thursday, January 09, 2003 4:53 PM
To: 'Roland Butler'; [EMAIL PROTECTED]
Subject: Not able to get current user logged into box
I am working on developing a script that will go out to a list of computers
that are on the network and determine who is currently logged onto the
workstations, these workstations are both NT 4.0 and 2000, the below script
seems to work with the 2000 workstations but not the NT 4.0 boxes. Can
someone point me in the current direction
thanks
robby
GetUser.pl
use Win32::TieRegistry;
$computer =
$Registry->{"\\\\navairns01\\HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\
Control\\ComputerName\\ActiveComputerName\\ComputerName"};
print "the computer is $computer\n";
$user =
$Registry->{"\\\\navairns01\\HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Window
sNT\\CurrentVersion\\WinLogon\\AltDefaultUsername"};
print "the user logged on is $user\n";
I would try using
$UserName = Win32::LoginName();
$Node = Win32::NodeName();
but if you want to use the registry try doing this
use Win32::TieRegistry;
$computer =
$Registry->{"\\\\navairns01\\HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\
Control\\ComputerName\\ActiveComputerName"};
$computer_name = $computer->GetValue(ComputerName);
print "the computer is $computer_name\n";
$user =
$Registry->{"\\\\navairns01\\HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Window
sNT\\CurrentVersion\\WinLogon"};
$user_name = $user->GetValue(AltDefaultUsername);
print "the user logged on is $user_name\n";
Either one depends on which one you like better, I know the first option
works on NT 4.0 and 2K because I have multiple scripts running that now.
Hope this helps
--Eric Hawley
ActivePerl mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs