Starting a VM with a Scheduled Task

Discussions related to using VirtualBox on Windows hosts.
Post Reply
Marius Roma
Posts: 3
Joined: 2. Mar 2015, 17:37

Starting a VM with a Scheduled Task

Post 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
Martin
Volunteer
Posts: 2562
Joined: 30. May 2007, 18:05
Primary OS: Fedora other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: XP, Win7, Win10, Linux, OS/2

Re: Starting a VM with a Scheduled Task

Post by Martin »

Did you make sure, that the scheduled task runs with the credentials of your normal user account?
Marius Roma
Posts: 3
Joined: 2. Mar 2015, 17:37

Re: Starting a VM with a Scheduled Task

Post 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
noteirak
Site Moderator
Posts: 5231
Joined: 13. Jan 2012, 11:14
Primary OS: Debian other
VBox Version: OSE Debian
Guest OSses: Debian, Win 2k8, Win 7
Contact:

Re: Starting a VM with a Scheduled Task

Post 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.
Hyperbox - Virtual Infrastructure Manager - https://apps.kamax.lu/hyperbox/
Manage your VirtualBox infrastructure the free way!
Post Reply