How to Fix a Windows Script Host Error

How to Fix a Windows Script Host Error
Page content

What is a Windows Host Script?

Windows Script Host is an administration tool in Windows operating systems, such as Windows 7, Vista, XP, Windows 2003, etc. Computer administrators can use Windows Script Host (WSH) to automate or administer some tasks for client computers or servers. Some software author will embed scripts to automate tasks using their program. You can run a script with two methods using a desktop – by double-clicking a script file or from a command prompt. WSH can be run from either the protected mode Windows-based host (Wscript.exe), or the real mode command shell-based host (Cscript.exe).

Some malware authors are taking advantage of WSH because it can be used to automate their malicious software. Antivirus and antispyware software vendors are aware of the security concerns on these files which is why it’s recommended to configure the antivirus software to scan all file types in Windows, and in real-time. Note that some security researchers or vendors recommend that you disable WSH in Windows as a preventive measure to protect from viruses that uses WSH. However, most antivirus programs have the ability to detect malicious scripts in a webpage or a file on a computer so it is not a requirement to disable or remove WSH.

The latest version of WSH is v5.8 which is included in Windows 7 computers. Other editions of Windows have version 5.7 or 5.6. Since version 5.6, a WSH can be digitally signed with a valid certificate.

A website that uses scripting can automatically load or run what the script is programmed to do, but Microsoft added security enhancements for Internet Explorer 4.0 and higher to treat WSH objects as unsafe ActiveX controls. End-users will see a dialogue box or warning within the browser if they want to continue running the script from the webpage they are visiting or viewing.

If you come across an error that is related to Windows Script Hosting, check out the solutions in the next sections of this article.

Common Errors

Not all types of script host errors are related to malware or virus infection on a computer. There are programs that require running a script but if the permission of the user account in Windows is limited or restricted, an error message will be displayed saying that it could not run the script. In some cases, if the computer has been configured to run a script file that does not exist anymore, a WSH error message will be displayed saying the system cannot locate the resource specified.

Users are encouraged to take note of the location and file name of the script file and verify if it’s a malware or a trusted program has added or using the script.

An example of a script file that was added by malware but couldn’t run anymore because it was removed or quarantined by an antivirus program is in the screenshot below:

The only solution to fix the above example of a Windows Script Host error message is to locate the script file by using Windows Explorer or the command prompt utility in Windows to manually delete the script added by the malware. You can also use the FileAssassin tool or the “Delete File on Reboot” option in Malwarebytes Anti-Malware or WinPatrol programs to remove locked, undeletable or nasty files from Windows.

General WSH Problems

If any legitimate script files or Windows programs that use a WSH couldn’t run due to corrupted WSH files, you can always try to fix the Windows script errors using the following steps below:

  • Re-register Windows Script Host components in Windows - you can automatically re-register WSH files by using the Microsoft Fix-It 50181 tool or manually re-register scripting components (see the next section on how to manually register scripting components).

  • Download and then reinstall Windows Script Hosting - if re-registering WSH components on your computer won’t help, it is recommended to re-install WSH. You can download it from the Microsoft Download Center website.

  • Check disk for errors - if re-installing WSH failed to fix script host errors, try to run the check disk utility in Windows to locate bad sectors and recover files. To do this, click Start, click Run, type cmd and then click OK. In the command prompt window, type chkdsk /r and then hit the Enter key on the keyboard. Note that if you are using Windows Vista or Windows 7, you will need to run the command prompt as administrator, by right-clicking on cmd.exe and then select “run as administrator”.

Register Components in Windows

To re-register WSH on a Windows computer, click Start, click Run, type cmd, and then click OK. Type regsvr32 %systemroot%\system32\vbscript.dll and then press the Enter key on your keyboard. Do the same by re-registering the following files:

  • jscript.dll
  • dispex.dll
  • scrobj.dll
  • scrrun.dll
  • wshext.dll
  • wshom.ocx

Note that if you are running a 64-bit edition of Windows using a 64-bit scripting file, you will need to type %systemroot%\system32\regsvr32 %systemroot%\system32\{filename here}.dll in the command prompt window. If you are using a 64-bit edition of Windows but running a 32-bit edition of scripting components, you will need to type %systemroot%\syswow64\regsvr32 %systemroot%\syswow64\[filename here}.dll.