我正在尝试从
python启动一个Power
Shell脚本,如下所示:
psxmlgen = subprocess.Popen([r'C:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe',
'./buildxml.ps1',
arg1, arg2, arg3], cwd=os.getcwd())
result = psxmlgen.wait()
问题是我收到以下错误:
File
C:\Users\sztomi\workspace\myproject\buildxml.ps1
cannot be loaded because the execution of scripts is disabled on this
system. Please see “get-help about_signing” for more details.
DESPITE这样一个事实,我在很久以前就通过在管理员运行的PS终端中键入Set-ExecutionPolicy Unrestrstriced(而且再次确定),在Powershell中启用了脚本. powershell可执行文件与开始菜单中的快捷方式相同. Get-ExecutionPolicy正确地报告无限制,无论我是否以管理员身份运行PowerShell.
如何从Python正确执行PS脚本?