OLE – s – Wscript.Network

The following script is really simple, and uses WScript.Network to get three sets of information for the current PC:

  • Domain, Computer Name and  User name
  • Network Drive Mapping
  • Network Printer mapping

newscript
dim WshNetwork = CreateObject("Wscript.Network")

Message = "Domain = " & WshNetwork.UserDomain & chr(0x0a) & _
"Computer Name = " & WshNetwork.ComputerName & chr(0x0a) & _
"User Name = " & WshNetwork.UserName

dim oDrives = WshNetwork.EnumNetworkDrives
dim oPrinters = WshNetwork.EnumPrinterConnections
dim i
freestring = " Network drive mapping:"
FOR i = 0 to oDrives.Count - 1 Step 2
freestring = freestring & chr(0x0a) & "Drive " & oDrives.Item(i) & " = " & oDrives.Item(i+1)
NEXT i
message = freestring

freestring = "Network printer mapping:"
FOR i = 0 to oPrinters.Count - 1 Step 2
freestring = freestring & chr(0x0a) & "Port " & oPrinters.Item(i) & " = " & oPrinters.Item(i+1)
NEXT i
message = freestring