Skip to content

Running Scripts is Disabled on this System – Fixing VS Code CMD Error

I will guide you on fixing the “Running Scripts is Disabled on this System” error in VS Code CMD.

Check your system’s security settings: If you encounter the “VS Code running scripts is disabled on this system” error, ensure that your system’s security settings are not blocking the execution of scripts. Temporarily disable any antivirus or security software and see if the issue persists.

Understanding the “running scripts is disabled on this system” error

Error message with disabled script icon

The “running scripts is disabled on this system” error in VS Code CMD occurs when the execution of scripts is not allowed. To fix this error, you need to change the execution policy in PowerShell. Here’s how you can do it:

1. Open PowerShell as an administrator.
2. Run the command Set-ExecutionPolicy RemoteSigned to allow the execution of local scripts.
3. Confirm the change by typing “Y” and pressing Enter.
4. Close PowerShell and restart Visual Studio Code.

By changing the execution policy, you enable the running of scripts on your system, resolving the error. This simple fix will allow you to run scripts without any issues. If you encounter any further problems, consider seeking assistance from relevant online communities like Reddit or referring to Microsoft’s official documentation.

The disabled script running capability in VS Code is a security measure to prevent potential harm caused by running untrusted or malicious code.

Adjusting the Execution Policy to enable script running

PowerShell command prompt with script icon

To enable script running in VS Code CMD and fix the “Running Scripts is Disabled on this System” error, you need to adjust the Execution Policy. Here’s how:

1. Open the Command Prompt as an administrator.
2. Type “Set-ExecutionPolicy Unrestricted” and press Enter.
3. When prompted, confirm the change by typing “Y” and pressing Enter.
4. Close the Command Prompt.

Now, you should be able to run scripts in VS Code CMD without encountering the error.

Temporary and permanent solutions for changing the Execution Policy

  • Temporary solution: Change the execution policy for the current session using the command line.
  • Permanent solution: Change the execution policy for all sessions on the system using the Group Policy Editor.
  • Temporary solution: Bypass the execution policy by running the script with the “-ExecutionPolicy Bypass” parameter.
  • Permanent solution: Modify the execution policy settings in the Windows Registry.
  • Temporary solution: Use the “-Scope CurrentUser” parameter to change the execution policy for the current user only.
  • Permanent solution: Use the “-Scope LocalMachine” parameter to change the execution policy for all users on the machine.
  • Temporary solution: Run the script from an elevated PowerShell session.
  • Permanent solution: Disable the execution policy completely using the “Unrestricted” option.
  • Temporary solution: Set the execution policy to “RemoteSigned” to allow execution of locally created scripts.
  • Permanent solution: Set the execution policy to “AllSigned” to require all scripts to be digitally signed.

powershell
$ExecutionPolicy = Get-ExecutionPolicy

if ($ExecutionPolicy -eq 'Restricted') {
Write-Host "Running scripts is currently disabled on this system."
} else {
Write-Host "Running scripts is enabled on this system."
}

This PowerShell code retrieves the current execution policy, which determines whether scripts are allowed to run. If the execution policy is set to “Restricted,” it means scripts execution is disabled. The code then outputs a message indicating whether scripts are enabled or disabled on the system.

Using PowerShell ISE and Group Policy Object for script execution

PowerShell ISE and Group Policy Object interface

Step Description
Step 1 Open PowerShell ISE
Step 2 Run the following command: Set-ExecutionPolicy -ExecutionPolicy RemoteSigned
Step 3 Press “Y” to confirm the change
Step 4 Close PowerShell ISE
Step 5 Open Group Policy Object Editor
Step 6 Navigate to Computer Configuration -> Administrative Templates -> Windows Components -> Windows PowerShell
Step 7 Double-click on Turn on Script Execution
Step 8 Select Enabled and choose Allow all scripts in the dropdown
Step 9 Click OK to save the changes
Step 10 Close Group Policy Object Editor
Step 11 Restart your computer
Was this article helpful?
YesNo