How to Disable VBS and JS Scripts Using Regedit

Malicious Visual Basic Scripts (.vbs) and JavaScript (.js) files are frequently used by attackers to execute payloads, bypass standard security controls, and deliver malware. In Windows, these scripts run automatically through the Windows Script Host (WSH). Disabling the script host or modifying script file associations directly via the Windows Registry Editor (Regedit) stops these scripts from running, effectively neutralizing this common infection vector.

Disabling the Windows Script Host prevents both .vbs and .js files (as well as .wsf and .vbe files) from executing on your system entirely.

  1. Press Win + R, type regedit, and press Enter to open the Registry Editor.

  2. Navigate to the following key:

    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Script Host\Settings
  3. Look for the Enabled value in the right pane:

    • If Enabled exists, double-click it, set the Value data to 0, and click OK.
    • If it does not exist, right-click an empty space in the right pane, select New > DWORD (32-bit) Value, name it Enabled, and set its Value data to 0.
  4. To apply this rule strictly to the current user profile as well, navigate to:

    HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows Script Host\Settings
  5. Repeat the process of creating or setting the Enabled DWORD value to 0.

Note: Once applied, any attempt to run a script file will display a prompt stating that Windows Script Host access is disabled.


Method 2: Remap File Associations to Open in Notepad

If you cannot disable Windows Script Host globally but want to prevent accidental execution, you can configure .vbs and .js files to open harmlessly in Notepad instead of executing.

For VBScript (.vbs) Files:

  1. In Regedit, navigate to:

    HKEY_CLASSES_ROOT\VBSFile\Shell\Open\Command
  2. Double-click the (Default) string in the right pane.

  3. Change the Value data to:

    %SystemRoot%\System32\Notepad.exe "%1"
  4. Click OK.

For JavaScript (.js) Files:

  1. In Regedit, navigate to:

    HKEY_CLASSES_ROOT\JSFile\Shell\Open\Command
  2. Double-click the (Default) string in the right pane.

  3. Change the Value data to:

    %SystemRoot%\System32\Notepad.exe "%1"
  4. Click OK.


Verifying the Changes

  1. Create a blank text file on your desktop.
  2. Rename it to test.vbs or test.js.
  3. Double-click the file.
  4. If Method 1 was used, an error prompt will block execution. If Method 2 was used, the file will safely open inside Notepad.