首先,
Set-ExecutionPolicy Unrestriced基于每个用户和每个位数(32位与64位不同)。
其次,您可以从命令行覆盖执行策略。
psxmlgen = subprocess.Popen([r'C:WINDOWSsystem32WindowsPowerShellv1.0powershell.exe', '-ExecutionPolicy', 'Unrestricted', './buildxml.ps1', arg1, arg2, arg3], cwd=os.getcwd())result = psxmlgen.wait()
显然,您可以使用以下路径从32位PowerShell访问64位PowerShell(感谢@eryksun):
powershell64 = os.path.join(os.environ['SystemRoot'], 'SysNative' if platform.architecture()[0] == '32bit' else 'System32', 'WindowsPowerShell', 'v1.0', 'powershell.exe')



