木子屋 Dnawo's BLOG

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

👤 dnawo 📅 2020-03-24 👁 2484 👍 0 💬 0 🔄 来源:本站原创
批处理调用PowerShell脚本:

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

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

图片

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

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

评论(0)

暂无评论。

验证码
评论需审核通过后显示
← 上一篇 RDPClient:简单小巧可代替TeamViewer免费远程桌… 下一篇 → 批处理调用PowerShell创建应用程序快捷方式示例