Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

getting loged on Username by VBScript

Status
Not open for further replies.

KiaKia

Programmer
Mar 30, 2008
59
US
Hi Everyone,
Please let me know how I can get the username currently loged on to the PC, within the Codes in a VBScript.

Thanks,
Kia

 
Dim oWSN:Set oWSN = CreateObject("WScript.Network")
WScript.Echo oWSN.UserName


[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
One way:
Code:
Set WshNetwork = CreateObject("WScript.Network")
MsgBox "Domain = " & WshNetwork.UserDomain _
 & vbCrLf & "Computer Name = " & WshNetwork.ComputerName _
 & vbCrLf & "User Name = " & WshNetwork.UserName

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top