vboxmanage guestcontrol change password

903 Views Asked by At

I have a script that inside a virtual machine I'm able to trigger.

However, I'd like to pass the argument to the script. I'd normally run the script as ">>test.bat user1"

The arguement is "user1". Can someone help modify the below command to pass the arguement?

VBoxManage --nologo guestcontrol "sample1" run --exe "C:\Users\sample1\Desktop\test.bat" --username sample1 --password sample2 --wait-stdout

I also tried running

VBoxManage --nologo guestcontrol "sample1" run --exe "C:\Users\sample1\Desktop\test.bat user1" --username sample1 --password sample2 --wait-stdout

But it was not right, I had results for above command as :

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

Also tried

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
2

There are 2 best solutions below

2
On

As I see it, this question has nothing to do with vboxmanage, and is simply a question of how to pass a reference a command line parameter within a batch file.

Within the batch file, the command line parameters are referenced as %1, %2, %3, etc. in the order they are presented on the command line. Thus:

Here's a simple, one-line bat file, named doit.bat

echo %1 %2 %3

And here's its execution:

C:\>doit firstparm secondparm thirdparm

C:\>echo firstparm secondparm thirdparm
firstparm secondparm thirdparm
3
On

From VBoxManage doc:

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]]

Please try

VBoxManage --nologo guestcontrol "sample1" run --exe "C:\Users\sample1\Desktop\test.bat" --username sample1 --password sample2 --wait-stdout -- user1

I was missing the -- in my previous comment