in reply to win32 get login name

I believe:
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!

Replies are listed 'Best First'.
Re: Re: win32 get login name
by softworkz (Monk) on Jan 10, 2002 at 01:46 UTC
    Thanks Jim!!
    Here's what I have so far, getting the book :)
    #!/usr/bin/perl -w use strict; use Win32; my $username = Win32::LoginName(); my $path = "u:\\profiler\\$username"; my $profile = "C:\\Documents and Settings\\$username" stat($path); exit if !-e _; # exit if the profile is not found system ("xcopy /i $path $profile");