Python执行错误

时间:2018-02-20 22:33:20

标签: python powershell

import subprocess
command = r'C:\Windows\system32\windowspowershell\v1.0\powershell.exe -noe -c ". \"C:\Program Files\VMware\VMware View\Server\extras\PowerShell\add-snapin.ps1\""'
subprocess.call(command,shell=True)

我使用此代码,但我在powershell

上收到了错误
add-PSSnapin : No snap-ins have been registered for Windows PowerShell version 5.
At C:\Program Files\VMware\VMware View\Server\extras\PowerShell\add-snapin.ps1:25 char:2

1 个答案:

答案 0 :(得分:0)

嗨试试这个: -

import os

command = r'C:\Windows\system32\windowspowershell\v1.0\powershell.exe -noe -c ". \"C:\Program Files\VMware\VMware View\Server\extras\PowerShell\add-snapin.ps1\""'
os.system(command)
#or
os.system(command,shell=True)