dtharby has asked for the wisdom of the Perl Monks concerning the following question:
Hi All,
Is it at all possible to get the current Logon ID of a user running a perl script ?
Basically I want to write a GUI front-end and would like
the script to be able to capture the user that is using the gui without them actually typing anything in.
Thanks in advance for your thoughts and ideas
Danny
Update :-- as marto and kaif have mentioned, I have managed to source a copy of Perl In A Nutshell.. :-)
Re: Windows Logon ID capture
by marto (Cardinal) on Jun 14, 2005 at 10:34 UTC
|
Win32::LoginName()
"Returns the username of the owner of the current Perl process." From Perl in a Nutshell (ISBN 1565922867) - 19.17 Win32 Extensions.
Hope this helps,
Cheers
Martin
| [reply] [d/l] |
|
| [reply] |
|
TANSTAAFL Its only "free" for 14 days. Then its $19.95 /month and up. I don't begrudge them their business though.
I have seen various bootleg copies mounted to the internet before. Be aware that is copyright infringement and the O'Reilly police will get you.
| [reply] |
|
|
Thanks Martin
I attempted to assign the value of Win32::Login() to a scalar ($script_runner) but I get the following error
Can't locate auto/Win32/Login.al in @INC
I have checked and it is indeed right
I am using ActiveState Perl 5.8 build 811
UPDATE: have used ppm to check for module but have had not luck finding the Win32 one....
| [reply] |
|
Hi,
Have you had a look here. Hope this helps.
Cheers,
Martin
| [reply] |
|
You will also need to put "use Win32;" in your script before you call the function. I don't think you'll need to PPM it, I believe its one of the core modules.
| [reply] [d/l] |
|
|
The function is Win32::LoginName
my $script_runner = Win32::LoginName;
# ^^^^
| [reply] [d/l] |
|
|