Share via


How to get the user running a VBScript

Hi all, welcome back,

It's very easy to find out the user name and the domain name of the user running a VBScript, and the computer name where it's running:

 

 Set objNet = CreateObject("WScript.NetWork") 

strInfo = "User Name is     " & objNet.UserName & vbCRLF & _
          "Computer Name is " & objNet.ComputerName & vbCRLF & _
          "Domain Name is   " & objNet.UserDomain

MsgBox strInfo

 

I hope this helps.

Cheers,

 

Alex (Alejandro Campos Magencio)

Comments

  • Anonymous
    July 16, 2008
    Hi Alex,How could I get the domain name of a user account that I specify?
  • Anonymous
    July 16, 2008
    LookupAccountName API may help you here:http://msdn.microsoft.com/en-us/library/aa379159(VS.85).aspxCheers,Alex
  • Anonymous
    May 14, 2009
    my e_mail:a26969@hotmail.comhow can I write above data into a report or table fields.thanks.