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
答案 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)