use Win32;
$login = Win32::LoginName;
will do what you want. For more detailed information, you
can also use this snippet from Learning Perl on Win32 Systems
(co-authored by our own merlyn):
use Win32::NetAdmin;
$user = Win32::LoginName; # grab the name of the current user
Win32::NetAdmin::UserGetAttributes("",
$username, $password, $passwordage,
$privilege, $homedir, $comment,
$flags, $scriptpath);
print "The homedir for $username is $homedir\n";
HTH,
--Jim
Update: Glad it works for you, although cut/paste may have caused you to drop a semicolon after your "my $profile" statement, but otherwise works for me! |