Reparar error de Windows Script Host paso a paso
In this article
Yes, you can repair the Windows Script Host error by re‑registering the script host executables and correcting any damaged registry keys that control their operation.
What You'll Need
- A Windows PC with administrative rights.
- Access to Command Prompt (cmd) or PowerShell.
- Basic familiarity with the Registry Editor (regedit).
- An internet connection for downloading the System File Checker tool, if needed.
Step-by-Step
- Confirm the error message. The most common text is “Windows Script Host has encountered an error” or “cscript.exe is not recognized”. Write down the exact wording; it helps later when searching for specific sub‑issues.
- Run a quick system restart. Many transient issues disappear after a reboot, so power the computer off, wait five seconds, and start it again.
- Open Command Prompt as Administrator. Press Windows+X and choose “Command Prompt (Admin)” or “Windows PowerShell (Admin)”. If the menu shows “Windows Terminal (Admin)”, that works as well.
- Re‑register the script host files. In the elevated prompt type the following two commands, pressing Enter after each:
regsvr32 %systemroot%\system32\wscript.exe
regsvr32 %systemroot%\system32\cscript.exe
You should see a confirmation dialog saying the registration succeeded. - Repair corrupted system files. Run the System File Checker by typing:
sfc /scannow
The tool will scan protected Windows files and automatically replace any that are damaged, including script host components. - Check the registry key that enables Windows Script Host. Press Windows+R, type
regedit, and press Enter. Navigate to:HKEY_LOCAL_MACHINE\Software\Microsoft\Windows Script Host\SettingsEnsure theEnabledDWORD value is set to1. If it is0or missing, right‑click the right pane, choose New → DWORD (32‑bit) Value, name itEnabled, and set the value to1. Close Regedit. - Reset file associations for .vbs and .js files. Still in the elevated prompt, run:
assoc .vbs=VBSFile
ftype VBSFile="%systemroot%\system32\wscript.exe" "%1" %*
Repeat for JavaScript files if you use them:assoc .js=JSFile
ftype JSFile="%systemroot%\system32\cscript.exe" "%1" %*
- Verify that the Windows Script Host service is not disabled by Group Policy. Open the Local Group Policy Editor by pressing Windows+R, typing
gpedit.msc, and pressing Enter. Navigate to:Computer Configuration → Administrative Templates → Windows Components → Windows Script HostEnsure the policy “Prevent access to Windows Script Host” is set to “Not Configured” or “Disabled”. If you see “Enabled”, change it, click Apply, then OK. - Test the fix. Create a simple test script. Open Notepad, paste the line
WScript.Echo "Test successful", save astest.vbson the desktop, then double‑click it. A message box should appear. If it does, the error is resolved.
Common Mistakes
1. Running commands without admin rights. Without elevation, the regsvr32 and sfc commands will fail silently or return “Access denied”. Always open the prompt with administrative privileges.
2. Editing the wrong registry path. The key for enabling the host lives under HKEY_LOCAL_MACHINE, not HKEY_CURRENT_USER. Changing the latter has no effect on the system‑wide error.
3. Deleting the Enabled value instead of setting it. Removing the DWORD leaves Windows uncertain about the host’s state; the safest action is to set it to 1.
4. Skipping the System File Checker. Corruption in other system components can masquerade as a script host problem. Running sfc /scannow catches these hidden issues.
Tips
- Keep a backup of the registry before making changes. In Regedit, choose File → Export and save a .reg file on an external drive.
- If you use PowerShell scripts (.ps1) alongside VBScript, make sure the execution policy is not set to
Restricted. RunGet-ExecutionPolicyand, if needed, change it withSet-ExecutionPolicy RemoteSigned -Scope CurrentUser. - Use the built‑in Windows Event Viewer (Windows Logs → Application) to view detailed error codes that appear when a script fails. The Event ID can point directly to a missing DLL or permission problem.
- When working on a corporate machine, Group Policy may be enforced centrally. If the local policy appears correct but the error persists, contact your IT administrator.
Troubleshooting
If the error persists after following the steps above:
- Run
DISM /Online /Cleanup‑Image /RestoreHealthfrom an elevated command prompt. DISM repairs the Windows image, which can resolve deeper component corruption. - Check for malware that specifically targets script host files. Run a full scan with Windows Defender or a reputable third‑party antivirus.
- Inspect file permissions on
wscript.exeandcscript.exe. Right‑click each file inC:\Windows\System32, choose Properties → Security, and ensure the “SYSTEM” and “Administrators” groups have “Read & execute” permissions. - Create a new user profile. Corruption limited to a user’s profile can cause script host failures. If a fresh account works, migrate your data and retire the problematic profile.
- Consider a repair install (in‑place upgrade). Boot from Windows installation media, choose “Upgrade” and keep files and apps. This refreshes core system components without a full clean install.
Frequently Asked Questions
Why does the error only appear when I run .vbs files?
The .vbs extension is explicitly handled by wscript.exe. If the file association is broken or the registry “Enabled” flag is set to 0, Windows cannot locate the host, producing the error.
Can disabling antivirus temporarily help?
Some security suites block script execution as a protective measure. Temporarily disabling the real‑time component can confirm whether the AV software is the cause, but remember to re‑enable it immediately after testing.
Is the Windows Script Host required for all Windows versions?
Yes. Windows 7, 8, 8.1, 10, and 11 all include WSH as a core component for legacy automation scripts. It is not optional and cannot be uninstalled through normal means.
What does error code 0x80070005 mean in this context?
0x80070005 translates to “Access denied”. It typically indicates insufficient permissions for the script host executable or for the registry key controlling it.
Will resetting the “Enabled” DWORD affect other scripts?
No. The DWORD only toggles whether the host can be launched. Setting it to 1 restores normal behavior for all script types that rely on WSH.
Do I need to reinstall Windows to fix a persistent WSH error?
Reinstalling is a last resort. Most WSH issues are resolved through re‑registration, system file repair, or DISM. Only consider a clean install if multiple core components are corrupted and other repair attempts fail.