如何向VM virtualbox发送指令subprocess.call?

2024-04-20 05:29:14 发布

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

我在virtualbox中有一个VM,可以用python启动机器

subprocess.call(["C:\...\VBoxManage.exe", "startvm", "my_vm"])

我怎么能跑知道abc.exe文件,位于桌面上? 根据下面的说明,这是不可能的。。在

^{pr2}$

Tags: 文件机器myvmcallexe桌面上subprocess
1条回答
网友
1楼 · 发布于 2024-04-20 05:29:14

run是一个关键字参数,因此在列表中将其设置为单独的项。在

subprocess.call(["C:\...\VBoxManage.exe", "guestcontrol", "my_vm", "run", "C:\\Users\\abc.exe"])

在Virtualbox docs的第二次审查中,它引用了:

run [common-options]
[ exe <path to executable>] [ timeout ]
[-E| putenv [=]] [ unquoted-args]
[ ignore-operhaned-processes] [ no-profile]
[ no-wait-stdout| wait-stdout] [ no-wait-stderr| wait-stderr]
[ dos2unix] [ unix2dos]
<program/arg0> [argument1] ... [argumentN]]

请参见<program/arg0>之前的参数。通常要接受后面的参数作为文字和外观要求,因此也要尝试:

^{pr2}$

相关问题 更多 >