How to get windows username using javascripts?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Eldann
    New Member
    • Mar 2014
    • 1

    #16
    Far too late to help abhishekitb, but it can be used by somebody else who asks the same question.

    Even if environment variables work well, as NeoPa said, this works too :
    Code:
    var ActX=new ActiveXObject("wscript.network");
    alert(ActX.username);
    Note that in the same way, you can get the computer and the domain name.
    Code:
    alert(ActX.computername);
    alert(ActX.userdomain);
    Tested on IE... 8... !!!, under Windows XP (sorry, nothing else at hand atm).

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32669

      #17
      People find these threads all the time Eldann, so abhishekitb not benefiting isn't the end of the world. Still worth posting :-)

      Comment

      Working...