Listing / Manipulating VMs for Another User
Posted: 17. Nov 2014, 09:08
I'd like to have my VMs start and stop with the host operating system (which is Windows 7). I've used Group Policy to set scripts that run when the machine starts up and when the machine shuts down. The Start up script works like a champ, starting the named VM in headless mode so that by the time user log-in happens it's already resumed and accepting network connections. The shutdown script, on the other hand, is not working during shutdown.
Start up Script:
Shutdown Script:
When I double click the shutdown script batch file it successfully suspends the VM and saves it's state. However, if I start the VM and then shut down the host, the script throws an error stating that it cannot find a VM with that name (later UUID as I thought that might help). The error message it presents is below.
I suspect this has something to do with VBoxManage not listing VMs from other Windows users. The shutdown script is likely running in the context of the System account, rather than my user. My question is, why can VBoxHeadless seem to be able to find the VM, despite also running under the System account? And how can I get VBoxManage to do the same? Utilizing the `runas` command in Windows is not an option because it requires entering the user's password (even if run from a privileged context such as System).
Start up Script:
Code: Select all
"C:\Program Files\Oracle\VirtualBox\VBoxHeadless.exe" -s "Ubuntu14.04"Code: Select all
"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" controlvm 09db26ba-2d24-42aa-a71d-668a220cfe18 savestateCode: Select all
VBoxManage.exe: error: Could not find a registered machine named '09db26ba-2d24-
42aa-a71d-668a220cfe18'
VBoxManage.exe: error: Details: code VBOX_E_OBJECT_NOT_FOUND (0x80bb0001), compo
nent VirtualBox, interface IVirtualBox, callee IUnknown
VBoxManage.exe: error: Context: "FindMachine(Bstr(a->argv[0]).raw(), machine.asO
utParam())" at line 95 of file VBoxManageControlVM.cpp