python多重执行命令

2024-10-02 18:18:44 发布

您现在位置:Python中文网/ 问答频道 /正文

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\""'
command2 = 'Get-PoolEntitlement -pool_id gameserver2 | Remove-
PoolEntitlement'
output = subprocess.getoutput(command)
output = subprocess.getoutput(command2)
print(output)

我已经运行了多个与命令相关的命令。但我没有

错误:

^{pr2}$

可操作程序或批处理文件。在


Tags: import命令outputwindowsexecommandvmwaresubprocess
2条回答

如果需要同时执行多个cmd命令,可以在它们之间加上“&;”。在

例如,cd documents&&start将导航到documents文件夹并启动一个新的命令提示符,希望这有帮助

你在召唤你的第一个命令:

command = r'C:\Windows\system32\windowspowershell\v1.0\powershell.exe -noe -c ". \"C:\Program Files\VMware\VMware View\Server\extras\PowerShell\add-snapin.ps1\""'

一秒钟之内你就不是了!在

^{pr2}$

所以你只需要纠正一下:

command2 = r'C:\Windows\system32\windowspowershell\v1.0\powershell.exe -noe -c "Get-PoolEntitlement -pool_id gameserver2 | Remove-PoolEntitlement"'

相关问题 更多 >