Fix Run VBS Error on Windows 10 – Step‑by‑Step Guide
In this article
Yes, you can fix the “Run VBS” error on Windows 10 by re‑enabling Windows Script Host, correcting the .vbs file association, and ensuring the script has proper permissions.
What You'll Need
- Administrator access to the computer
- A basic text editor (Notepad or similar)
- Command Prompt (run as administrator)
- Optional: Registry Editor (regedit)
Step‑by‑Step
-
Confirm the error. Double‑click any
.vbsfile. If Windows shows a message such as “Windows cannot open this file” or “Run VBS error”, note the exact wording – it usually means the script host is disabled or the file association is broken. -
Check whether Windows Script Host is disabled. Open Win + R, type
regeditand press Enter. Navigate toHKEY_LOCAL_MACHINE\Software\Microsoft\Windows Script Host\Settings. If theEnabledDWORD exists and is set to0, double‑click it and change the value to1. Close the Registry Editor and restart the computer. -
If the registry key is missing, create it. Right‑click the
Settingsfolder, choose New > DWORD (32‑bit) Value, name itEnabled, and set the value to1. Restart. -
Use Group Policy (Windows 10 Pro or Enterprise). Press Win + R, type
gpedit.mscand press Enter. Browse toComputer Configuration → Administrative Templates → Windows Components → Windows Script Host. Double‑click Enable Windows Script Host and set it to Enabled. Click OK and rungpupdate /forcefrom an elevated command prompt. -
Repair the .vbs file association. Open an elevated Command Prompt (right‑click Start, choose Windows Terminal (Admin) or Command Prompt (Admin)). Run the following two commands one after the other:
assoc .vbs=VBSFile ftype VBSFile="%SystemRoot%\System32\WScript.exe" "%1" %*
These commands tell Windows that.vbsfiles belong to theVBSFiletype and that the type should be opened withWScript.exe. -
Verify the default app for .vbs files. Open Settings > Apps > Default apps > Choose default apps by file type. Scroll to
.vbsand ensure the default is Windows Script Host. If it shows something else, click the entry and select Windows Script Host. -
Check file permissions. Right‑click the problematic
.vbsfile, choose Properties > Security. Ensure your user account (or the Administrators group) has Read & Execute permission. If not, click Edit, check the box, and apply. -
Run a system file check. Corrupted system files can also prevent the script host from launching. In the elevated Command Prompt, type
sfc /scannowand press Enter. Wait for the scan to finish and follow any on‑screen instructions. -
Test the script again. Double‑click the
.vbsfile. If the script runs (or at least the Windows Script Host dialog appears), the issue is resolved. - Optional: Re‑install Windows Script Host via optional features. Open Settings > Apps > Optional features > Add a feature. Look for “Windows Script Host” (if listed) and install it. This step is rarely needed but can help on heavily modified systems.
Common Mistakes
- Changing the
Enabledvalue to0instead of1. This re‑disables the host and reproduces the error. - Editing the wrong registry hive. The key must be under
HKEY_LOCAL_MACHINE, notHKEY_CURRENT_USER, for system‑wide effect. - Running the
assocorftypecommands without administrator rights. Without elevation the commands silently fail. - Forgetting to restart after changing registry or Group Policy settings. The changes are not applied until the next logon or a manual restart.
- Leaving antivirus software to block
WScript.exe. Some security suites quarantine the executable, causing the same error.
Tips
- Create a backup of the
Settingsregistry key before editing. Right‑click the key, choose Export, and save the .reg file. - If you manage many computers, deploy the registry change via a .reg file or PowerShell script to keep the process consistent.
- Use
where wscript.exein Command Prompt to confirm the executable exists in%SystemRoot%\System32. - When testing, use a simple script such as
MsgBox "Hello"saved astest.vbs. This isolates the host from script‑specific errors. - If you suspect a third‑party program is interfering, perform a clean boot (disable non‑Microsoft services) and retry the script.
Troubleshooting
If the steps above do not resolve the issue, follow this escalation path:
-
Confirm
WScript.exeis present. OpenC:\Windows\System32and verifyWScript.exeandCscript.exeexist. If either file is missing or corrupted, copy them from a known‑good Windows 10 installation or runsfc /scannowagain. - Check for software conflicts. Temporarily disable any third‑party security suites, script‑blocking extensions, or system‑optimisation tools. Restart and test the script.
-
Run a DISM repair. In an elevated Command Prompt, execute:
DISM /Online /Cleanup‑Image /RestoreHealth
After DISM finishes, runsfc /scannowonce more. - Inspect the Event Viewer. Press Win + X, choose Event Viewer. Look under Windows Logs > Application for errors with source “Windows Script Host” or “WScript”. The details often point to missing DLLs or permission problems.
-
Create a new user profile. Corrupted user profiles can inherit broken file‑type associations. Create a local administrator account, log in, and test a
.vbsfile. - Perform an in‑place upgrade. If none of the above works, download the latest Windows 10 ISO from Microsoft, run the setup, and choose “Keep personal files and apps”. This refreshes system components without a full clean install.
Frequently Asked Questions
Why does double‑clicking a .vbs file show “Windows cannot open this file”?
The most common cause is that Windows Script Host has been disabled via the registry or Group Policy, breaking the default handler for .vbs files.
Can I run a .vbs script from PowerShell instead of double‑clicking?
Yes. Open PowerShell as administrator and type cscript "C:\Path\YourScript.vbs". This bypasses file‑type association but still requires the script host to be enabled.
Is it safe to enable Windows Script Host on a corporate PC?
Enabling the host restores normal functionality, but administrators should ensure that only trusted scripts are executed and that endpoint protection is configured to scan .vbs files.
What does the registry value Enabled = 0 actually do?
It tells Windows to refuse launching any Windows Script Host process, effectively disabling both WScript.exe and Cscript.exe for all users.
Will resetting file associations affect other file types?
No. The assoc .vbs=VBSFile command only changes the association for the .vbs extension. Other file types remain untouched.
My antivirus still blocks .vbs files after I fix the host. What now?
Add an exclusion for WScript.exe and the folder containing your scripts, or consult the security software’s documentation for allowing script execution.