How can I use a script to quickly get information about current username, computer name, and domain?

John Savill

October 12, 2006

1 Min Read
ITPro Today logo in a gray background | ITPro Today

A. The following script, which you can download here , queries the network object from a VBScript script and outputs current information.

Dim objNetOn Error Resume Next Set objNet = CreateObject("WScript.Network") If err.Number <> 0 Then 'If error occured then display notice    Wscript.Echo "Error create Network object" & err.number, err.description    err.ClearEnd ifWscript.Echo "User Name is " & objNet.UserNameWscript.Echo "Computer Name is " & objNet.ComputerNameWscript.Echo "Domain Name is " & objNet.UserDomainSet objNet = Nothing

About the Author

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like