36

In 2013 I tracked down how to autostart/shutdown a Virtualbox VM when the host is Linux. The process was officially documented and required a few steps.

Right now I am interested in, how do you configure Virtualbox VM to autostart after Windows-10 reboot?

Is there an officially documented process? If not, what are some person's tested solutions?

My naive attempt was going to be something like:

  • done: Setup windows to auto-login upon reboot

  • TODO: Create batch script with: sleep 120 && vboxmanage startvm my_vm_name

  • TODO: Put the batch script into my user's startup directory. (I didn't see any "startup" directory in windows 10 though...)

  • i wasn't sure about using the startup menu... because it is very windows-9x-ish (maybe it's older). In linux I used sysvinit/systemd but I'm just not familiar with Windows (maybe task-scheduler or some such). – Trevor Boyd Smith Jan 17 '16 at 2:46
  • Could be useful if you add a link to The process was officially documented on linux ;-) – Philippe Gachoud Oct 3 '18 at 11:17
  • @PhilippeGachoud as per your request, i edited the question and added a link to the documentation – Trevor Boyd Smith Oct 3 '18 at 17:24
  • Thx! I found this more adequate because less sensible to changes of packages managment configuration as seems to be the case, whats your experience with that? medium.com/@bharatman/… – Philippe Gachoud Oct 3 '18 at 17:56
34

The start up directory does still exist, albeit in a well hidden place...

Access it via opening the "Run" box (Win+R) and entering

shell:startup

Minimise this for now.

Open VirtualBox and right click on the VM you want to autostart, click the option to create a shortcut on the desktop and close VirtualBox.

Simply cut the shortcut from the desktop and paste it into the previously opened folder and it should be perfectly fine.

  • 4
    shell:startup is on login, not on system boot, correct? How to do this on system boot? – alexei Jan 1 '17 at 17:00
  • 1
    You need to run it as a service – AKi Jan 26 '17 at 19:33
  • 1
    Not necessarily. You can always configure autologon, Open a cmd and type control userpasswords2. You'll find your way through the rest. – Eduardo Oct 26 '18 at 4:48
11

Try VBoxVmService

Make sure to read the Howto.txt and edit VBoxVmService.ini

  • 1
    Thank you so much! this looks very promising. On Windows, the lack of Virtualbox integration with system start/shutdown was always a big negative when you wanted to compare windows-virtualbox vs linux-virtualbox (even tho the linux virtualbox integration is only sysvinit... and is IMO not very robust (shutdown of VMs does not wait for the VM to shutdown before system issues SIGKILL and then does system shutdown)). – Trevor Boyd Smith May 20 '16 at 15:50
  • 1
    I tried this about a year ago. This solution requires that you update virtualbox in lockstep with the wrapper code that does the windows service. And so you have to be careful. Also a windows update i think broke this functionality for me. And so i ended up uninstalling this vbox-service code. – Trevor Boyd Smith Jul 26 '17 at 13:04
  • I looked at this project. The sheer volume of spelling mistakes makes me worry about similar issues in the code. Mineshaft+canary. – user2066657 Sep 13 '18 at 15:45
  • @user2066657 well you can read my comments and see that I tried it and it worked for a little bit then got broken. your concerns about spelling mistakes indicating the quality of code is probably well founded. i still would not go back to it today. – Trevor Boyd Smith Oct 3 '18 at 17:34
11

You can actually start a VM headlessly without resorting to a third-party VBoxVmService now. Just create a shortcut to <VirtualBoxDirectory\VBoxManage.exe> startvm "vmname" --type headless and put that in your startup folder.

From the VirtualBox manual.

  • 5
    Doesn't this still have the disadvantage of requiring login instead of just running on boot? – HorusKol May 20 '17 at 1:34
  • Of course. A service is still a necessity if you want to run anything without having to log in. – rustyx Sep 5 '17 at 12:12
  • 2
    Use a Scheduled Task for that instead of shortcut in the startup folder. – Bruno Finger Jun 14 '18 at 12:52
6

While having a Service is nice, you can do it with a scheduled task. Take system boot as the trigger, check the option to run the task without a logged-on user and set the action to <VirtualBoxDirectory\VBoxManage.exe> startvm "vmname" --type headless. Make sure to remove the check from the incomprehensibly default-on option "kill the task if running for more than 3 days". Srsly, MS, what were you thinking, that no Windows computer would ever last that long without reboot?

There is a caveat: if a VM is started on boot that way, you will see it in the VirtualBox Manager as "powered off", so there's no button to show the display of the VM. There's only the "start" button and you will probably screw things up when you try to double-start it.

You can define a remote display port so that you can access the console of the VM thru RDC (mstsc.exe), without the VirtualBox Manager, but you still have to remember to not believe the "powered off" information. I don't know if that works better with a real service.

  • 1
    re "having a Service is nice". unfortunately the VirtualBox service gets broken everytime there is a minor virtualbox update. so i ended up uninstalling the service and right now my VM does not start at boot anymore. – Trevor Boyd Smith Mar 17 '18 at 17:53
  • re "[the VM shows up as] powered off [in VirtualBox Manager]" i believe this is caused by the way you are starting the VM. i suspect you are starting the VM as the root user. if you were to try and start the VM with a "runas" your user... your VirtualBox manager might work. – Trevor Boyd Smith Mar 17 '18 at 17:57
  • 1
    now that i think of it... the VirtualBox service... ALSO shows up as "powered off" when you start it via the service. – Trevor Boyd Smith Mar 17 '18 at 17:58
  • 1
    This looks very promising, but I can't get it to work... I created the job, with two commands -- to start my too "main" VMs. I see it in scheduler. I can click on it a pick "Run" -- the state changes from "Ready" to "Running", but the VMs do not start. Nor do they start upon boot... There must be something else to it... – Mikhail T. Aug 1 '18 at 20:10
  • IT WORKS, tested on Windows 10 + Virtualbox 6.0.2. Recipe: Windows-key, type SCHED and launch task scheduler, Create Basic Task, Trigger: When the computer starts, Action: Start a program, Program (browse to VBoxManage.exe), arguments: startvm "vmname" --type headless, tick "Open the properties dialog for this task.. and finish, tick Run whether user is logged on or not, perhaps remove Conditions/Start only if the computer is on AC power, and Settings/Stop the task if it runs longer than.. (though really that one does not matter here since the launch is fast). – fgrieu Jan 18 at 8:25
2

As previously stated by chad and gonesoft, you can use VboxManage.exe to start the VM on launch, however, if you do not specify "--type headless" it will actually show up in the VirtualBox Manager as running etc. just like as if you had started it normally, headless is what makes it hidden - not something you'd likely want to do in all cases...

Posting as answer as i don't have enough reputation to write a comment to the previous answers

2

Try VBoxHeadlessTray.
It's really easy to use, which automatically restore VM's state when Windows boot up and save state when Windows shutdown or restart. What the most awesome is you can use VBoxHeadlessTray to configure each one of your VMs.

  • that looks amazing. i'll have to try it out when i have time. thanks. – Trevor Boyd Smith Jul 26 at 14:32

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.