powershell - Visual Studio 代码 cmd 错误 : Cannot be loaded because running scripts is disabled on this system

标签 powershell command-line visual-studio-code vscode-settings

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

File C:\Theses_Repo\train-cnn\environment\Scripts\activate.ps1 cannot be loaded because running scripts is disabled on this system.



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

最佳答案

我发现了 here您可以添加到您的 visual studio code settings以下问题将消失:
对于 Visual Studio 代码设置,转到文件 -> 首选项 -> 设置 -> 扩展 -> 向下滚动并找到“在 settings.json 中编辑”。不要忘记重新启动visual studio代码

"terminal.integrated.shellArgs.windows": ["-ExecutionPolicy", "Bypass"]
原因是,在构建命令行集成(如 Visual Studio 代码)中,您需要自行设置命令行策略。通过设置上述配置,visual studio 代码将为您完成。
(阅读 this 以更好地了解命令行策略)

关于powershell - Visual Studio 代码 cmd 错误 : Cannot be loaded because running scripts is disabled on this system,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56199111/

相关文章:

Python 3 - 如何在命令行窗口中创建打字效果

python - 在 0.074 秒内以代码 = 0 退出 - 输出窗口在 Visual Studio 中没有输出

powershell - 使用 PowerShell 下载安全文件

powershell - Google Drive API - 具有域范围权限的服务帐户可以列出共享驱动器,但不能列出其内容

java - 如何使用包含双引号的参数从 Java 启动进程

Linux查找没有文件的文件夹,但只查找子文件夹

带有黑名单(排除)和白名单(包括)的 Powershell 复制文件

powershell - 在Powershell中获取Windows中可用于Docker的全局最大内存

c++ - 如何在 VS Code 中编译 c/c++ 时禁用自动创建 exe 文件?

c++ - VS 代码 "command": "make" differs from command line `make` in terminal window