我有一个可以在虚拟机中触发的脚本。
但是,我想将参数传递给脚本。我通常会以">>test.bat user1“的身份运行脚本
论据是"user1“。有人可以帮助修改下面的命令来通过论证吗?
VBoxManage --nologo guestcontrol "sample1" run --exe "C:\Users\sample1\Desktop\test.bat" --username sample1 --password sample2 --wait-stdout我也试着跑
VBoxManage --nologo guestcontrol "sample1" run --exe "C:\Users\sample1\Desktop\test.bat user1" --username sample1 --password sample2 --wait-stdout但这是不正确的,我对上面的命令有如下结果:
C:\Program Files\Oracle\VirtualBox>VBoxManage --nologo guestcontrol "sample3" run --exe "C:\Users\sample1\Desktop\test.bat user1" --username sample1 --password sample2 --wait-stdout
VBoxManage.exe: error: No such file or directory on guest
VBoxManage.exe: error: Details: code VBOX_E_IPRT_ERROR (0x80bb0005), component GuestProcessWrap, interface IGuestProcess, callee IUnknown
VBoxManage.exe: error: Context: "WaitForArray(ComSafeArrayAsInParam(aWaitStartFlags), gctlRunGetRemainingTime(msStart, cMsTimeout), &waitResult)" at line 1485 of file VBoxManageGuestCtrl.cpp也尝试过
VBoxManage --nologo guestcontrol "sample1" run --exe "C:\Users\sample1\Desktop\test.bat" --username sample1 --password sample2 --wait-stdout --user1
Usage:
VBoxManage guestcontrol <uuid|vmname> [--verbose|-v] [--quiet|-q]
[--username <name>] [--domain <domain>]
[--passwordfile <file> | --password <password>]
run [common-options]
[--exe <path to executable>] [--timeout <msec>]
[-E|--putenv <NAME>[=<VALUE>]] [--unquoted-args]
[--ignore-operhaned-processes] [--profile]
[--no-wait-stdout|--wait-stdout]
[--no-wait-stderr|--wait-stderr]
[--dos2unix] [--unix2dos]
-- <program/arg0> [argument1] ... [argumentN]]
VBoxManage.exe: error: Unknown option: --user1发布于 2020-07-23 20:15:51
在我看来,这个问题与vboxmanage无关,只是关于如何在批处理文件中传递命令行参数引用的问题。
在批处理文件中,命令行参数按照它们在命令行上的显示顺序引用为%1、%2、%3等。因此:
下面是一个简单的、只有一行的bat文件,名为doit.bat
echo %1 %2 %3下面是它的执行过程:
C:\>doit firstparm secondparm thirdparm
C:\>echo firstparm secondparm thirdparm
firstparm secondparm thirdparm发布于 2020-07-23 20:38:21
来自VBoxManage文档:
VBoxManage guestcontrol <uuid|vmname> run [common-options] --exe <path to executable>
[--timeout <msec>] [-E|--putenv <NAME>[=<VALUE>]] [--unquoted-args]
[--ignore-operhaned-processes] [--profile] [--no-wait-stdout|--wait-stdout]
[--no-wait-stderr|--wait-stderr] [--dos2unix] [--unix2dos] -- <program/arg0> [argument1] ... [argumentN]]请尝试
VBoxManage --nologo guestcontrol "sample1" run --exe "C:\Users\sample1\Desktop\test.bat" --username sample1 --password sample2 --wait-stdout -- user1我在之前的评论中遗漏了--
https://stackoverflow.com/questions/63053455
复制相似问题