我正在嘗試從
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腳本?