Tuesday, September 2, 2008

Get the user name, machine name, and domain, via vbscript

Most of what I'm typing below I got from....
http://www.codeproject.com/KB/vbscript/userinfo.aspx

Open a text file, past the the text below and save it as a .vbs file.....

Dim objNet
Set objNet = CreateObject("WScript.NetWork")

Dim strInfoUserName
strInfoUserName = "User Name is " & objNet.UserName

Dim strInfoMachineName
strInfoMachineName = "Computer Name is " & objNet.ComputerName

Dim strInfoDomainName
strInfoDomainName = "Domain Name is " & objNet.UserDomain

MsgBox strInfoUserName
MsgBox strInfoMachineName
MsgBox strInfoDomainName



Here are the properties of the Network Object of WScrip.

Computer Name A string representation of the computer name.

UserDomain A string representation of the user's domain.

UserName A string representation of the user name.

These are the methods of Network Object of WScript.

AddPrinterConnection Maps a remote printer to a local resource name.

EnumNetworkDrives Returns the current network drive mappings.

EnumPrinterConnections Returns the current network drive mappings.

MapNetworkDrive Maps a share point to a local resource name.

RemoveNetworkDrive Removes the current resource connection.

RemovePrinterConnection Removes a current resource connection.

SetDefaultPrinter Sets the default printer.

No comments: