Starting Virtualbox VM’s in headless mode before user login

I have two virtualmachines that I need to start automatically, preferably without a window taking up space in my taskbar, when my computer starts up.  One runs FreePBX, the other is a web host for my development sites.  Virtualbox takes care of the headless aspect with vboxheadless.exe, but how do you get that to start automatically on computer boot?

First, download HSTART.  This is a small executable that allows a program to be started and run in the background.  You can get it at http://www.ntwind.com/software/hstart.html – extract the downloaded files to C:\Program Files\HSTART

Then, create a new directory to hold your startup script.  I put mine at C:\Startup

Paste the following into a batch file in the startup folder:

"C:\Program Files\HSTART\hstart64.exe" /NOCONSOLE /SILENT "C:\Program Files\Oracle\VirtualBox\vboxheadless.exe --startvm "Debian Dev Hosting""
"C:\Program Files\HSTART\hstart64.exe" /NOCONSOLE /SILENT "C:\Program Files\Oracle\VirtualBox\vboxheadless.exe --startvm "FreePBX""

Modify the VM names, and add as many lines as you want.

Next, click on Start -> Right click on Computer -> Select Manage.  Go to the Scheduled Tasks, and hit the Create Task… action.  Configure the task as follows:

  • General
    • Name: Whatever you wish to name this task
    • Change User or Group:  Click this button, and search for Administrators.  This should add the BUILTIN\Administrators group
    • Run with highest privileges: Select this checkbox
  • Triggers
    • Click new, and change the Begin the task: dropdown to read At Startup
  • Actions
    • Click new
      • Action:  Change this dropdown to read Start a program
      • Program/Script:  Insert the path to the batch file you created
  • Conditions
    • Modify these options as needed.  I didn’t change anything here
  • Settings
    • Make sure the following options are selected:
      • Allow task to be run on demand
      • If the running task does not end when requested, force it to stop

Click ok.  Now, under Task Schedular you should see a Task Scheduler Library – click that, right click on your Start Virtual Machine task, and select Run.

I’ve found that this will *not* show the machines as running in the Virtualbox gui – likely because they are not running under the current user.  To validate they are running, either look in your task manager for the vboxheadless.exe processes, or attempt to log in to your machines via SSH/RDP/Any other enabled remote protocol (after giving the VM ample time to boot that is.)

 

Leave a Reply

  • (will not be published)

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>