How do you configure Virtualbox VM to autostart after Windows-10 reboot?

40

6

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...)

Trevor Boyd Smith

Posted 2016-01-17T02:26:17.523

Reputation: 2 093

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 – 2016-01-17T02:46:01.893

Could be useful if you add a link to The process was officially documented on linux ;-) – Philippe Gachoud – 2018-10-03T11:17:46.853

@PhilippeGachoud as per your request, i edited the question and added a link to the documentation – Trevor Boyd Smith – 2018-10-03T17:24:35.093

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? https://medium.com/@bharatman/how-to-autostart-and-autostop-your-headless-virtualbox-guest-vm-on-a-debian-host-3ca7ede2380b

– Philippe Gachoud – 2018-10-03T17:56:13.333

Answers

38

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.

Sam3000

Posted 2016-01-17T02:26:17.523

Reputation: 2 730

4shell:startup is on login, not on system boot, correct? How to do this on system boot? – alexei – 2017-01-01T17:00:51.767

1

You need to run it as a service

– AKi – 2017-01-26T19:33:21.327

1Not necessarily. You can always configure autologon, Open a cmd and type control userpasswords2. You'll find your way through the rest. – Eduardo – 2018-10-26T04:48:59.507

15

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.

Chad

Posted 2016-01-17T02:26:17.523

Reputation: 151

5Doesn't this still have the disadvantage of requiring login instead of just running on boot? – HorusKol – 2017-05-20T01:34:36.447

Of course. A service is still a necessity if you want to run anything without having to log in. – rustyx – 2017-09-05T12:12:51.423

2Use a Scheduled Task for that instead of shortcut in the startup folder. – Bruno Finger – 2018-06-14T12:52:18.053

12

Try VBoxVmService

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

AKi

Posted 2016-01-17T02:26:17.523

Reputation: 228

1Thank 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 – 2016-05-20T15:50:33.933

1I 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 – 2017-07-26T13:04:22.697

I looked at this project. The sheer volume of spelling mistakes makes me worry about similar issues in the code. Mineshaft+canary. – user2066657 – 2018-09-13T15:45:50.973

@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 – 2018-10-03T17:34:36.293

8

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.

gonesoft

Posted 2016-01-17T02:26:17.523

Reputation: 81

1re "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 – 2018-03-17T17:53:47.447

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 – 2018-03-17T17:57:37.897

1now that i think of it... the VirtualBox service... ALSO shows up as "powered off" when you start it via the service. – Trevor Boyd Smith – 2018-03-17T17:58:10.573

1This 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. – 2018-08-01T20:10:45.297

1*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 – 2019-01-18T08:25:23.043

3

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.

chengxuncc

Posted 2016-01-17T02:26:17.523

Reputation: 33

that looks amazing. i'll have to try it out when i have time. thanks. – Trevor Boyd Smith – 2019-07-26T14:32:17.777

Works perfectly. Great late answer! – FloPinguin – 2020-01-15T20:17:13.333

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

Swizzy

Posted 2016-01-17T02:26:17.523

Reputation: 21