Sunday, April 1, 2007

Network Information

' Illustrates the use of the Network object to enumerate connections.

Dim net, coll, i

' Instantiate a WshNetwork object
Set net = WScript.CreateObject("Wscript.Network")

WScript.Echo "Current network settings..."
WScript.Echo ""

' Now print information about the current computer, domain, and user
WScript.Echo "Computer: " & net.ComputerName
WScript.Echo "Domain: " & net.UserDomain
WScript.Echo "User: " & net.UserName

' List the network drive mappings
WScript.Echo ""
WScript.Echo "Network drive mappings:"
Set coll = net.EnumNetworkDrives()
For i = 0 to coll.Count - 1
WScript.Echo coll(i)
Next

' List the printer mappings
WScript.Echo ""
WScript.Echo "Printer mappings:"
Set coll = net.EnumPrinterConnections()
For i = 0 to coll.Count - 1
WScript.Echo coll(i)
Next

No comments:

Related Titles

 
visitors since March 26 2007
©2007