Visual Studio 代码 cmd 错误:无法加载,因为在此系统上禁用了运行脚本 [英] Visual studio code cmd error: Cannot be loaded because running scripts is disabled on this system

查看:23
本文介绍了Visual Studio 代码 cmd 错误:无法加载,因为在此系统上禁用了运行脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Visual Studio 代码中,我尝试从命令行执行 script.bat,但出现以下错误:

Inside of visual studio code, I'm trying to execute a script.bat from the command line, but I'm getting the following error:

文件 C:Thes_Repo rain-cnnenvironmentScriptsactivate.ps1 无法加载,因为在此系统上禁用了运行脚本.

File C:Theses_Repo rain-cnnenvironmentScriptsactivate.ps1 cannot be loaded because running scripts is disabled on this system.

阅读之后这 我试图以管理员模式运行visual studio代码,认为问题是权限问题.但无论如何都会抛出错误.

After reading this I tried to run the visual studio code in administrator mode, thinking that the problem was a matter of privileges. But the error is throwing anyway.

推荐答案

我发现了 此处 您可以将其添加到视觉工作室代码设置以下问题将消失:对于 Visual Studio 代码设置,转到 File ->首选项 ->设置 ->扩展 ->向下滚动并找到在 settings.json 中编辑".不要忘记重启visual studio代码

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"]

原因是,在构建命令行集成(如 Visual Studio 代码)中,您需要自行设置命令行策略.通过设置上述配置,visual studio 代码会为你做这些.

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.

(阅读 this 以更好地理解命令行策略)

(read this to understand better the command line policies)

2021 年 8 月更新

terminal.integrated.shellArgs 似乎已被弃用.答案显示了如何在新版本中执行此操作.

It seems that terminal.integrated.shellArgs is deprecated. This answer shows how to do it in new versions.

这篇关于Visual Studio 代码 cmd 错误:无法加载,因为在此系统上禁用了运行脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆