Visual studio code cmd error: Cannot be loaded because running scripts is disabled on this system

This article will show you, via a series of examples, how to fix the Cannot Be Loaded Because Running Scripts Is Disabled On This System Visual Studio Code problem that occurs in code.

ng : File C:\Users\sam\AppData\Roaming\npm\ng.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at https:/
At line:1 char:1

  • ng new ang
  • ~~
    • CategoryInfo : SecurityError: (:) [], PSSecurityException
    • FullyQualifiedErrorId : UnauthorizedAccess

The simplest way to deal with this problem from Visual Studio Code is to change from powerShell to cmd (assuming there’s no reason for using powershell in your case). To do so, follow these few steps:

First Method

File -> Preferences -> Settings and in the search bar write “automation”.

After that, by looking your operating system enter “edit in settings.json”.

Finally, add the following b/n the braces:

"": ["-ExecutionPolicy", "Bypass"]

add following in vscode > settings.json

"": {
  "PowerShell": {
    "source": "PowerShell",
      "icon": "terminal-powershell",
        "args": ["-ExecutionPolicy", "Bypass"]
"": "PowerShell"

Second Method

  1. Press the windows-button on your keyboard
  2. Type ‘PowerShell’
  3. Right-click Windows PowerShell
  4. Click Run as Administrator
  5. Run the following command and confirm with ‘Y’
  6. Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine


Technologies get updated, syntax changes and honestly… I make mistakes too. If something is incorrect, incomplete or doesn’t work, let me know in the comments below and help thousands of visitors.

Leave a Reply

Your email address will not be published. Required fields are marked *