How-to: A list of useful WScript properties

Properties of the WScript object:

WScript.Application
This property is read only and returns a reference to the current WScript instance.

WScript.BuildVersion
This property is read only and returns a Long value which is the build version number of cscript (or wscript).

WScript.FullName
This property returns the full path to cscript (or wscript). This property is read only.

WScript.Interactive [= True|False]
The Interactive property returns a Boolean that indicates if cscript (or wscript) was invoked in interactive mode. This property is read/write and can be used to change the mode of the currently executing script at runtime.
When this property is False, the interactive commands Echo, MsgBox and InputBox have no effect.

WScript[.Name]
The Name property is read only and returns the name of the WScript object (usually "Windows Script Host").
This is the default property of the WScript object.

WScript.Path
This property is read only and returns the full path to the directory containing cscript (or wscript).

WScript.ScriptFullName
This property is read only and returns the full path to the script currently being executed.

WScript.ScriptName
This property is read only and returns the filename of the script currently being executed.

WScript.StdErr
This property returns a TextStream object that outputs text to the Standard Error stream.
This property is read only and can only be used when cscript is the host executable.

WScript.StdIn
The StdIn property returns a TextStream object that reads text from the Standard Input stream.
This property is read only and can only be used when cscript is the host executable.

WScript.StdOut
This property returns a TextStream object that outputs text to the Standard Output stream.
This property is read only and can only be used when cscript is the host executable.

WScript.Timeout[ = lngTimeout]
This property is used to set or get the timeout period (in seconds) for the currently executing script. The script will automatically be terminated after the number of seconds specified by this property, which is of type Long.

WScript.Version
This property is read only and returns a string that is the version number of the host executable.

Examples

'Output the version of Microsoft Windows Script Host.
strVer = WScript.Version
WScript.Echo strVer


'Output the full path-name of the currently running script.
strFull = WScript.ScriptFullName
WScript.Echo strFull

'The Application property returns a reference to the current instance of the WScript object.
Set objWScript = WScript.Application
If WScript = objWScript Then
 WScript.Echo "This proves they refer to the same thing"
End If

“Never underestimate the power of intrinsic values. They inspire every struggle for a better world” ~ George Monbiot

Related VBScript commands

.CreateObject - Create a WSH automation object.
cscript - Run a VBScript .vbs file.


 
Copyright © 1999-2024 SS64.com
Some rights reserved