The wscript.Network object

Provides access to the shared resources on the network to which your computer is connected.

      Set WshNetwork = CreateObject("Wscript.Network") 


    UserName     The username variable, likely the SAM Account Name (the pre-Windows 2000 name)
    UserDomain   The NetBIOS domain name
    ComputerName This is the NetBIOS computer name


    AddWindowsPrinterConnection Add a printer in Windows 2000 and higher
    AddPrinterConnection    Add a printer in older systems
    EnumNetworkDrives       List the mapped drives on the computer
    EnumPrinterConnections  List the installed printers
    MapNetworkDrive         Map a network drive
    RemoveNetworkDrive      Remove a network drive
    RemovePrinterConnection Remove a printer connection
    SetDefaultPrinter       Set the default printer


Set WshNetwork = WScript.CreateObject("WScript.Network")
WScript.Echo "Domain = " & WshNetwork.UserDomain
WScript.Echo "Computer Name = " & WshNetwork.ComputerName
WScript.Echo "User Name = " & WshNetwork.UserName

“It is possible to store the mind with a million facts and still be entirely uneducated” ~ Alec Bourne

Related VBScript commands

Shell + Shell.Application objects/methods.

Copyright © 1999-2024
Some rights reserved