Installing VirtualBox as a Service on Windows Using NSSM

In this article, we will guide you through the process of installing VirtualBox as a Windows service using NSSM (Non-Sucking Service Manager) and starting a Virtual Machine automatically as a service. This can be useful for scenarios where you need a Virtual Machine to run in the background, even when the user is not logged in.

Prerequisites

Before we begin, ensure that you have the following prerequisites in place:

  1. VirtualBox: You should have VirtualBox installed on your Windows machine. You can download it from the official VirtualBox website.

  2. NSSM (Non-Sucking Service Manager): NSSM is a tool that allows you to create and manage Windows services. We recommend installing it via Chocolatey (Choco), a popular package manager for Windows. If you haven’t installed Choco, you can download and install it from the Chocolatey website.

    To install NSSM using Chocolatey, open a Command Prompt with administrator privileges and run the following command:

    1
    
    choco install nssm

Installing VirtualBox as a Service

Now, let’s proceed with installing VirtualBox as a Windows service:

  1. Open Command Prompt as Administrator: Right-click on the Command Prompt icon and select “Run as administrator” to ensure you have the necessary privileges.

  2. Install VirtualBox as a Service: Run the following NSSM command to install VirtualBox as a service. Replace <VIRTUAL-MACHINE_NAME> with the name of your Virtual Machine:

    1
    
    nssm install VirtualBoxVM
  3. Configure Service Parameters:

    • Application Path: Set the path to the VBoxHeadless.exe executable. By default, it’s located in “C:\Program Files\Oracle\VirtualBox\VBoxHeadless.exe.”

      1
      
      Path: C:\Program Files\Oracle\VirtualBox\VBoxHeadless.exe
    • Arguments: Specify the -startvm parameter followed by the name of your Virtual Machine.

      1
      
      Arguments: -startvm <VIRTUAL-MACHINE_NAME>

    NSSM Configuration

  4. Save Configuration: Click on the “Install service” button to save the configuration. You should see a message indicating that the service has been installed.

  5. Start the Service: You can start the service immediately using the following command:

    1
    
    net start VirtualBoxVM

    This command will start your Virtual Machine as a service.

Managing the VirtualBox Service

You’ve successfully installed VirtualBox as a Windows service using NSSM. To manage the service, you can use standard Windows service management tools or commands, such as:

  • To start the service:

    1
    
    net start VirtualBoxVM
  • To stop the service:

    1
    
    net stop VirtualBoxVM
  • To check the status of the service:

    1
    
    sc query VirtualBoxVM

Now, your Virtual Machine will run as a service, allowing you to use it without the need for manual intervention, even when you are not logged into the system.

0%