Create whatever Virtual Machine you want to run as a service using what is normal for you.
- Recommended to ensure the network address is known. For example, set a static IP.
- Recommended to setup SSH access, VNC, or RDP ahead of time.
Download onlyfang's VboxVmService tool.
I usually install this tool into a simple location like
VBoxVmService.inifile in the
C:\bin\vmservicefolder. In the ini file, you need to specify the the location of the VM metadata created by VirtualBox GUI (i.e. VBOX_USER_HOME). The VBOX_USER_HOME value is typically a user folder like
C:\Users\<user>\.VirtualBox. Then each virtual machine that you want to run as a service is added as an indexed entry. For example, the entry with
VmName=desktop-ubuntu-devis the first Virtual Machine to run as a service.
- Reboot your machine and ensure that you can access the Virtual Machine.
The VBoxVmService tool runs the configured VMs as a Windows Service, which in turn is executed as the local SYSTEM user. This means that if you want to modify the VM whiles its running as a service, you'll want to run
VirtualBox.exe as the SYSTEM user.
Pre-Req: Install SysInternals
My initial inclination is to use the old
runas.exe tool. This will not work because
runas predates the new security model since Windows Vista. Instead I prefer to use
psexec which is part of the Microsoft provided SysInternals Suite.
Download the SysInternals Suite zip file.
Extract the SysInternals zip file into a simple and known folder (e.g.
Note: Unlike many other compressed file distributions, SysInternals does not have an internal folder. If you extract here, it's going to dump a hundred some files directly into that directory.
Add SysInternals path (
C:\bin\sysinternals) to the user's PATH environment variable.
Edit windows environment variables by doing on of the following:
- Right Click "My PC", Click Properties, Advanced System Settings (next to related links), Advanced Tab, Environment Variables Button
- Run within a command prompt:
Once the path is set, reset any relevant terminals or command applications to register the new environment variables. SysInternals is not installed.
Running VirtualBox as SYSTEM
From command prompt (run as Administrator), run:
psexec -i -s cmd.exe. This'll launch a secondary prompt that is running as SYSTEM.
Within the SYSTEM command prompt, you can use
VBoxManage.exeas you usually would or you can launch the
In theory you can run
psexec -s cmd.exe as a entry point for Windows Terminal. The issue is that whenever I've attempted this there has been other issues with how things like tab complete work or how the environment variables are set. When I tried running
psexec -i -s wt.exe, the STDIN wasn't working. If I felt this was something I was going to be needed more often, I'd suggest looking at some of the other third party tools that allow running commands as SYSTEM.