Page 1 of 1

Starting a VM with a Scheduled Task

Posted: 2. Mar 2015, 17:43
by Marius Roma
I need to start a VM with a scheduled task in a Windows 7 64bit host.
I created a .vbs file like the following one:

Code: Select all

Set WshShell = WScript.CreateObject("WScript.Shell")
ReturnCode = WshShell.Run("""c:\program files\oracle\virtualbox\vboxmanage.exe"" startvm ""My_VM_name"" --type headless", 0, True)
and a scheduled task that looks like:

Code: Select all

CScript.exe //Nologo //B F:\Work\start_vm.vbs
If I run the .vbs script manually with the same parameters it works fine; if I try to start the scheduled task nothing happens.
How can I solve the issue?
Is there any documentation I can read?
Regards

marius

Re: Starting a VM with a Scheduled Task

Posted: 2. Mar 2015, 17:47
by Martin
Did you make sure, that the scheduled task runs with the credentials of your normal user account?

Re: Starting a VM with a Scheduled Task

Posted: 2. Mar 2015, 18:07
by Marius Roma
I set the credentials of my domain user's account with local administrator's rights.
Should I use a local Administrator account?
Regards
Marius

Re: Starting a VM with a Scheduled Task

Posted: 12. Mar 2015, 10:21
by noteirak
VirtualBox use a global configuration per user, and can see VMs status on a per security context basis (same user under the same type of elevation).
Your issue right now is that the system user does not have a VirtualBox profile, and I would recommend not using it. Go for a dedicated technical account.

If you want to run a VM from a scheduled task, you need to first create a proper profile for the technical user used for the scheduled task (run VirtualBox with "Run As...") or by using an already existing user.
No need to run as administrator.