How to Run a VirtualBox Virtual Machine as a Windows Service

Xavier Mustin

Administrator
Staff member
#1
How to Run a VirtualBox Virtual Machine as a Windows Service with AlwaysUp

Ensure that your VirtualBox VM starts immediately when your PC boots and is available 24/7


VirtualBox is an free, open-source virtualization platform that can host Windows, Linux, Solaris and other operating systems.

To configure VirtualBox with AlwaysUp 6.0 and later:

Download and install AlwaysUp, if necessary.

Download and install VirtualBox, if necessary.Be sure to install the VirtualBox extension pack if you intend to use VirtualBox'sRemote Display feature to connect to your VM.

Please make a note of the VirtualBox installation directory (by default, C:\Program Files\Oracle\VirtualBox) as this will be used in subsequent steps.

Next, configure your VirtualBox VM for remote access via RDP. Start VirtualBox, highlight your VM in the list and choose Machine > Settings. Select Display on the left and move over to the Remote Display tab.Check the Enable Server box and enter a port number in the Server Port field. We recommend using a number between 7000 and 8000 and we have used 7070 in our setup.



Start AlwaysUp.

Select Application > Add to open the Add Application window:



On the General tab:


  • In the Application field, enter the full path to theVBoxHeadless.exe application, which allows you to start a VM without a graphical interface.If you installed VirtualBox in the default location, this is:C:\Program Files\Oracle\VirtualBox\VBoxHeadless.exe

    In the Arguments field, enter:-startvm <VIRTUAL-MACHINE_NAME>where <VIRTUAL-MACHINE_NAME> is the name of the VirtualBox VM you would like to start automatically.We have specified Win8DevPreview.

    In the Name field, enter the name that you will call the application in AlwaysUp.We have used Win8DevPreview VM but you can specify virtually anything you like.



Click over to the LogOn tab:


  • Enter the user name and password of the account in which you installed and run VirtualBox.Your VM will run in this account so that it can find its settings.



Click over to the Startup tab and check the Ensure that the Windows Networking components have started box.This informs AlwaysUp that VirtualBox needs the TCP/IP networking stack to operate.



Move to the Extras tab and:


  • Check the Use this special command to stop the application box.Specify the full path to the VBoxManage.exe application along with a few arguments:"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" controlvm <VIRTUAL-MACHINE-NAME> savestatewhere <VIRTUAL-MACHINE-NAME> is the name of your VM (again, Win8DevPreview in our situation).See the VBoxManage.exe command line arguments for stopping a VM if you wish to stop without saving state, etc.

    Check the Wait for up to: box and enter 30 in the accompanying field. This informs AlwaysUp to wait for up to 30 seconds for VirtualBox to exit properly before forcibly closing it.



Click the Save >> button. In a couple of seconds, an application called Win8DevPreview VM will show up in the AlwaysUp window.It is not yet running though.



To start the VirtualBox VM, choose Application > Start "Win8DevPreview VM" (your application name will be different!).After starting, we connected via RDP ( at localhost:7070) to confirm that the VM is running properly.



That's it! Next time your computer boots, your VirtualBox VM will start up immediately, before anyone logs on.We encourage you to edit your application in AlwaysUp and check out the many other settings that may be appropriate for your environment.
 

Fichiers joints

Haut