[英]python multiple execute command
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)
我已经运行了多个与命令相关的命令。 但是我不
错误:
'Get-PoolEntitlement' is not recognized as an internal or external command,
可操作的程序或批处理文件。
如果您需要一次执行多个cmd命令,则可以在它们之间加上“ &&”。
例如, cd documents&&start
会导航到documents文件夹并启动一个新的命令提示符,希望这会有所帮助
在第一个命令中,您正在调用PowerShell:
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'
因此,您只需要像这样纠正即可:
command2 = r'C:\Windows\system32\windowspowershell\v1.0\powershell.exe -noe -c "Get-PoolEntitlement -pool_id gameserver2 | Remove-PoolEntitlement"'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.