Inside of visual studio code, I\'m trying to execute a script.bat from the command line, but I\'m getting the following error:
File C:\\Theses_Repo\\t
If you don't need to explicitly run this on PowerShell, then you may want to try running it in the command prompt.
Just type cmd
and press enter. Doing so will open the command prompt in the current terminal window. It will behave same as a normal command prompt.
Open VS code
File -> Prefrences -> settings
in the Search bar -> Search for "terminal.integrated.shellArgs"
Click on the "Edit in setting.json" for Terminal>integrated>ShellArgs > windows [whatever you OS, select the respective settings]
At the top of the json file add this :
terminal.integrated.shellArgs.windows": ["-ExecutionPolicy", "Bypass"]
For example after adding your json might look like:
{ "terminal.integrated.shellArgs.windows": ["-ExecutionPolicy", "Bypass"], "git.autofetch": true, "peacock.favoriteColors": [ { "name": "Angular Red", "value": "#b52e31" }, { "name": "Auth0 Orange", "value": "#eb5424" },
For more simplicity, I want to add the vs code settings path in addition to Ricardo's answer. you can get it like this:
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:
"terminal.integrated.shellArgs.windows": ["-ExecutionPolicy", "Bypass"]
For security reasons, in case you share the computer with other users, use: PowerShell:
Set-ExecutionPolicy -Scope CurrentUser Unrestricted
No need for Admin privileges.
I have faced the same problem due to security reasons on Windows 10. I managed to fix it by running the following command in PowerShell:
Set-ExecutionPolicy -ExecutionPolicy Unrestricted
I found out here that you can add to your visual studio code settings the following and the problem will vanish: For visual studio code settings, go to File -> Preferences -> Settings -> Extensions -> Scroll down and find "Edit in settings.json". Do not forget to restart the visual studio code
"terminal.integrated.shellArgs.windows": ["-ExecutionPolicy", "Bypass"]
The reason is that, in build command line integrations like visual studio code, you need to set the command line policies by your self. By setting the above configurations, the visual studio code will do that for you.
(read this to understand better the command line policies)