6

Objective

I want to run this command VBoxManage startvm MyVM --type headless at the boot system just like a service (postgres, apache) does.

What i've tried

1. I've tried to create a service using sc command

I've found over the internet that could be the solution so i tried all this versions:

  • sc create "vboxMyVMService" binPath= "C:\Progman Files\Oracle\VirtualBox\VBoxManage.exe startvm MyVM --type headless"

  • sc create "vboxMyVMService" binPath= "C:\Progman Files\Oracle\VirtualBox\VBoxManage startvm MyVM --type headless"

No success, so i tried to suppress the verbose output of the command

  • sc create "vboxMyVMService" binPath= "C:\Progman Files\Oracle\VirtualBox\VBoxManage.exe startvm MyVM --type headless > NUL"

  • sc create "vboxMyVMService" binPath= "C:\Progman Files\Oracle\VirtualBox\VBoxManage startvm MyVM --type headless"

Still no results. All this version returned me a 1053 error. So the last call was to add the Virtualbox command to the Path


  • sc create "vboxMyVMService" binPath= "VBoxManage.exe startvm MyVM --type headless"

  • sc create "vboxMyVMService" binPath= "VBoxManage startvm MyVM --type headless"

suppressing output

  • sc create "vboxMyVMService" binPath= "VBoxManage.exe startvm MyVM --type headless > NUL"

  • sc create "vboxMyVMService" binPath= "VBoxManage startvm MyVM --type headless > NUL"

No positive result always 1053 error.

2. Assign Computer Startup Scripts

I followed this tutorial with my last hope, but no success.

What left

I'm thinking about to download the Visual Studio and try something related to create a service project.


So guys, where is my mistake? Is there hope to me?


FAQs

  1. Can you switch you OS to linux?

    • No. It's out of question.
  2. Why you need this VM to startup at with the system?

    • Unfortunately this windows 7 host is a small server for the application running over the VM. The machine it's not mine and it's the only option they gave to me to make the deploy.
  3. Why you are not making the deploy of the application inside the windows host?

    • I'm not running PHP, or any .NET stuff, so no.
  • Rather simpler. Have you tried using Task Scheduler with an "On Startup" trigger? Though you might actually need something more like "At log on" depending on whether you need to give time for other services to start which I suspect you do. – Julian Knight Jun 2 '15 at 23:04
  • what about sticking the vbox X --type headless command in a batch script that you stick in the Startup folder, or in the HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run .. does it have to be a service? Just curious if you need the netstart functionality over just starting the VM in headless mode at startup? – txtechhelp Jun 2 '15 at 23:41
  • @JulianKnight i need the vm running without the need to login on a specific account :( But i will check the Scheduler see if can be a plan B – vyscond Jun 3 '15 at 0:29
  • @txtechhelp didn't find anything about this folder, i will try it in a minute too. – vyscond Jun 3 '15 at 0:30
  • Trying using srvany as the service executable and use that to launch your VBoxManage command. Seems like the task scheduler idea on startup would also work. – ssnobody Jun 3 '15 at 0:45
8

I run with NSSM.

Create a NSSM service in prompt like:

  1. nssm/win64/nssm.exe install vbox

  2. Select exec VBoxHeadless.exe like image:

    NSSM install service

  3. Use your Windows Account in Logon (this is very important)

  4. Install service

Works for me.

  • Great program. I used "startvm WindowsXP --type headless" as my arguments. Works great – Peter Berbec Feb 14 '18 at 8:59
  • When stopping such service, it always does hard shutdown of VM? I do not see mechanism to NSSM wait till machine shutdown correctly. – user2956477 Jul 23 at 18:00
4

I wasn't able to find a mechanism to start a VM as service with VBoxManager command without anybody required to login first.

I enabled my Ubuntu Server VM to run as service using the VBoxVmService tool. http://vboxvmservice.sourceforge.net/

Brief Description: VBoxVmService is a Windows application that allows you to run Oracle's VirtualBox VMs from within a native Windows service entity.

The main reason i required this is, to start the VM without anybody required to login. Mine being a developer workstation, it get's restarted for updates, and i sometimes forget to start the VM until someone pokes me.

Here's how it works:

  • Ensure the required VM starts and works fine without errors. Else will be tough to debug digging through the logs.
  • Upon installation VMBoxService set's it's executable as a windows service
  • Edit it's configuration INI file (Refer here for full documented sample)
  • Reboot the machine or just start the VMBoxService's installed windows service
  • Following is a sample INI

    [Settings]
    VBOX_USER_HOME=C:\Users\YOUR_NAME_HERE\.VirtualBox
    PauseShutdown=8000
    [Vm0]
    VmName=ubuntu-server                                              
    ShutdownMethod=savestate                                    
    AutoStart=yes
    
  • Might be worth improving your answer. Good software recommendations answers are 'how' not 'what'. Maybe edit your answer to talk about how you would use this software to start your vm as a service and what's the advantages of this. – Journeyman Geek Jun 15 '16 at 23:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.