Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: How to get system user name from windows using perl

by Anonymous Monk
on Nov 10, 2011 at 12:32 UTC ( #937365=note: print w/ replies, xml ) Need Help??


in reply to How to get system user name from windows using perl

my name and acronym and department e.t.c. how can I get that name directly from windows system.

Never heard of a windows system maintaining such information, but if you can retrieve it from the registry, you could use Win32::TieRegistry

Also, %ENV contains lots of information, like USERPROFILE...


Comment on Re: How to get system user name from windows using perl
Re^2: How to get system user name from windows using perl
by Sinistral (Prior) on Nov 10, 2011 at 14:01 UTC

      Au contraire, Windows absolutely does maintain the current user information.

      Where is the department name? Acronym, e.t.c?

      Reading comprehension is fun :)

        That information is available via Exchange, Active Directory, or other corporate directory structure. A standalone Windows workstation doesn't maintain such details. They can be retrieved easily, but unless the OP says what infrastructure exists in their organization we can't help

Re^2: How to get system user name from windows using perl
by Lotus1 (Chaplain) on Nov 10, 2011 at 15:19 UTC

    Type SET at the command prompt to get a list of available environment variables on a Windows system.

    $ENV{USERNAME} for example.

      Caveat: %ENV is always byte semantics, if you have an oldish Windows and a username outside of the ANSI locale, you get question marks. One should be using Win32ís LoginName() instead which always returns character-shaped characters.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://937365]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (11)
As of 2014-11-27 08:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (182 votes), past polls