批处理调用PowerShell脚本提示在此系统上禁止运行脚本解决方法

批处理调用PowerShell脚本:

powershell.exe -command "&{%~dp0demo.ps1}"

运行出错,提示无法加载文件,因为在此系统上禁止运行脚本:



这是由于没有权限执行PowerShell脚本,修改批处理赋于执行权限即可:

powershell.exe -command "& {set-executionpolicy Remotesigned -Scope Process; .'%~dp0demo.ps1' }"


评论: 0 | 引用: 0 | 查看次数: 1626
发表评论
登录后再发表评论!