getting the username

im trying to get the username from the system...

i have read somewhere that the way u get this i s as follows...

Environment.UserName();

but this does not want to work....

does anybody have any ideas.

thanks flipmode



Answer this question

getting the username

  • psn

    When you say "this does not want to work", what do you exactly mean Are you getting errors, or no results, or something that is not expected

    The following works for me on my XP machine:

    import System; 
    var username = System.Environment.UserName; 
    print(username);
    For example: 
    F:\>whoami
    MYPC\administrator
    
    F:\>a.exe 
    Administrator
    

    Hope it helps.

    -Matteo



  • coloso

    It should work -

    syntax:

    Environment.Username - returns a string

    What is the entire code you are using That line I have mentioned alone gives you a string back of the current user RUNNING the CURRENT process (i.e the application thread)



  • Naim4u

    I tried this and I get an error 19(syntax error) on the import System line

    what version of Jscript are you running

    thanks,

    Daryl


  • Kurt Brockett

    Hi,

    What if I want to get the current logged on windows user Not the current process user.

    Cos if I use Environment.Username in ASP.net, it returns ASPNET as user. I've enabled Anonymous Login for the site as I do not want to use Intergrated Windows Login. I just want the current windows username.


  • getting the username