Wednesday, October 29, 2014

An A-Z Index of Windows Scripting Host commands (WSH/VB Script)

An A-Z Index of Windows Scripting Host commands (WSH/VB Script)


Arguments, display - WshArguments.Item (also Count and length)

Command, cscript - Run a VBS/WSH Script
Command, .Run command
Command, .Exec execute command
Command, .AppActivate activate running command

Drive Map - .MapNetworkDrive
Drive Map, list - .EnumNetworkDrives
Drive Map, remove - .RemoveNetworkDrive

Echo text .Echo
Echo text to StdOut.Write
Echo, popup .Popup
Environment, read env variables - .Environment
Environment, expand env variables - .ExpandEnvironmentStrings
Environment, delete env variables - .WshEnvironment.Remove
Environment, echo .ComputerName
Environment, echo .UserName
Environment, echo .UserDomain

Log an item in the Event log .LogEvent

Object, create - .CreateObject
Object, get - .GetObject
Object, disconnect- .DisconnectObject

Path of wscript.exe - .Name
Path to current directory - .CurrentDirectory
Pathname of wscript.exe - .FullName
Pathname of script being run - .ScriptFullName
Path to desktop,start menu.. - .SpecialFolders
Printer, add printer - .AddPrinterConnection
Printer, add Network printer - .AddWindowsPrinterConnection
Printer, list printers - .EnumPrinterConnections
Printer, set default printer - .SetDefaultPrinter
Printer, remove printer - .RemovePrinterConnection

Quit - .Quit

Registry, delete - .RegDelete
Registry, read - .RegRead
Registry, write - .RegWrite

Send Keys - .SendKeys
Shortcut,create - .CreateShortcut
Sleep - .Sleep

text input - .ReadLine
text output - .Write
Version of wscript - .Version

Syntax
Variables, Functions, Operators,
Conditional and looping Statements.

Examples:
DriveMap.vbs - Connect to a network file share.
qchange.vbs - Re-assign network printer connections
compinfo.vbs - List Computer properties (as shown in ADUC)
userinfo.vbs - List User properties (as shown in ADUC)
datetime.vbs - Get Date, Time and daylight savings
uname.vbs - List user's simple name when called with a Distinguished Name
Localadmins.vbs - List local administrators across a network domain

All the syntax on this page assumes you have Windows Scripting Host version 5.6 (as supplied with Windows XP.) Examples are in VB Script.
Windows Scripting Host 5.7 is also now available.

No comments:

Post a Comment