Windows Script Host

Also known as: WSH

On this page 7

Windows Script Host (WSH) is the language-independent scripting runtime built into Microsoft Windows that runs script files written in VBScript and JScript, exposing objects for working with files, the registry, network drives and other programs. Within PowerShell & command line administration, it is the predecessor of PowerShell: the tool administrators used to automate Windows before PowerShell existed, and one that still runs on most systems today.

WSH first shipped with Windows 98 and was offered as an add-on for Windows 95 and Windows NT 4.0. It remained the standard way to write logon scripts and administrative automation for roughly a decade, until PowerShell took over that role. Microsoft now treats it as legacy technology, and VBScript is on a published path toward removal.

How Windows Script Host runs a script

Windows Script Host works as a host process that loads an Active Scripting engine chosen by the file extension and then runs the script inside that engine. The host itself does not understand any language; it provides the environment, the built-in WScript object and access to COM automation objects that do the real work.

Two host executables exist, and they differ mainly in how they handle output. The table below compares them.

HostOutput styleTypical use
wscript.exeMessage boxes in graphical windowsDefault host when a user double-clicks a script
cscript.exeText written to the consoleScheduled tasks, logon scripts and command-line automation
The two Windows Script Host executables

Running cscript //H:cscript changes the default host so that double-clicked scripts send output to a console. Useful switches include //B for batch mode without prompts, //Nologo to hide the banner and //T:nn to set a timeout in seconds that stops a runaway script.

Script file types and languages

Windows Script Host selects the scripting engine from the file extension, and each extension has a distinct format and purpose. Administrators who encounter these files in logon folders, scheduled tasks or email attachments should recognize them immediately.

ExtensionLanguage or formatNotes
.vbsVBScriptMost common format for administrative scripts
.jsJScriptMicrosoft dialect of ECMAScript 3, not a browser script
.wsfXML Windows Script FileCan combine several languages and include other files
.vbe and .jseEncoded VBScript or JScriptObfuscated source, not real encryption
.wshSettings fileStores host options for a specific script
File extensions handled by Windows Script Host

The .wsf format is the most capable because its XML wrapper supports named arguments, usage help and references to type libraries. Encoded files only hide the source from casual reading; tools that reverse the encoding are widely known, so they provide no real protection for credentials stored inside.

Key objects exposed to scripts

The value of Windows Script Host comes from the COM objects that scripts create with CreateObject. These objects give access to the shell, the file system, the network and Windows Management Instrumentation.

ObjectProvided byMain capabilities
WScriptHost, always availableArguments, output, sleep and quit
WScript.ShellWSH object modelRun programs, read and write registry, environment variables
WScript.NetworkWSH object modelMap network drives and printers, read user and computer names
Scripting.FileSystemObjectScripting Runtime libraryCreate, read, copy and delete files and folders
WMI via GetObjectWMI serviceQuery hardware, services and processes
Frequently used objects in WSH scripts

A classic logon script, for example, uses WScript.Network to map a departmental drive letter and WScript.Shell to write a registry value. Because these objects run with the permissions of the current user, a script can change anything that user is allowed to change.

Windows Script Host compared with PowerShell and batch files

WSH sits between batch files and PowerShell in capability. It offers real variables, functions and objects that batch files lack, but it has no pipeline, no remoting and only limited access to the .NET platform.

CriterionBatch fileWindows Script HostPowerShell
Data modelText stringsCOM objects.NET objects in a pipeline
Error handlingExit codes onlyOn Error Resume Next or try-catch in JScriptStructured try-catch-finally
Remote executionNot built inNot built inPowerShell remoting
Execution controlNoneRegistry switch onlyExecution policy and logging
StatusSupportedLegacy, VBScript deprecatedActively developed
Comparison of Windows scripting options

For new automation, PowerShell is the recommended choice. WSH knowledge remains useful mainly for maintaining existing scripts and for recognizing malicious files during incident response.

Security risks and the deprecation of VBScript

Windows Script Host is a frequent tool of attackers because a double-clicked .js or .vbs file runs immediately with the user’s rights and without the execution policy that protects PowerShell. Email campaigns have long used such attachments as first-stage malware droppers.

Microsoft has responded on several fronts. Scripts run through WSH are scanned by the Antimalware Scan Interface (AMSI), and attack surface reduction rules can block obfuscated scripts or scripts that launch downloaded content. In 2023 Microsoft announced that VBScript would be deprecated: it became a feature on demand in Windows 11, version 24H2, and is planned to be disabled by default and later removed.

  • Set the Enabled value to 0 under the Windows Script Host settings registry key to disable WSH on machines that do not need it.
  • Change the file association so that .js and .vbs files open in a text editor instead of running.
  • Inventory existing VBScript logon and maintenance scripts and migrate them to PowerShell before removal.
  • Never store plain-text passwords in scripts, encoded or not.

The simple explanation

Windows Script Host is an older built-in helper in Windows that reads small instruction files and carries them out. An administrator could write a short text file saying, in effect, connect this network drive, copy these files and set this option, and Windows would follow those steps automatically.

It is a bit like an old recipe card that still works in a modern kitchen. Newer tools such as PowerShell do the same jobs better and more safely, so Microsoft is gradually retiring the old approach. Because criminals also send such files by email, it is wise to treat unexpected script attachments as dangerous.

How it is used in practice

A school district runs a VBScript logon script, written in 2008, on about 900 classroom computers. Through Group Policy it runs with cscript.exe //B //Nologo, maps two network drives with WScript.Network and writes a printer setting to the registry with WScript.Shell.

After Microsoft announced the VBScript deprecation, the district’s systems administrator rewrote the script in PowerShell, replacing drive mapping with New-PSDrive and registry writes with Set-ItemProperty. The team then disabled Windows Script Host on student machines and changed the .js and .vbs associations to Notepad. During the next phishing wave, two students opened a malicious .js attachment, and the file simply opened as text instead of running, which prevented an infection.