How stop virtualbox from command line

Product:

VirtualBox https://www.virtualbox.org/wiki/Downloads

Microsoft Windows 10

Issue:
How stop virtual box vms from command line before computer shutdown?

Suggestion: (this may not work)

Create text files in a c:\scripts folder with the command you need to start and stop vms.
Important: that case of the vms name matched the name you have given them inside Virtualbox.

Create a CMD file with following command:

rem stop one virtualbox image
"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" list runningvms

"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" controlvm "win2012big" acpipowerbutton
"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" controlvm "Win2016 CAPA" acpipowerbutton

Add the file to group policy on the computer:

  1. In a command window, open the Group Policy Editor (GPE) by running gpedit.msc.
  2. Expand Computer Configuration and select Windows Settings.
  3. Double-click Scripts (Startup/Shutdown).
  4. Click Add and add c:/scripts/vboxshutdown.cmd.

Add the start script (c:/scripts/vboxstart.cmd) to the Start properties.

Create a CMD file with following command to start:

rem start one virtualbox image
"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" startvm "Win2016 CAPA"
"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" startvm "Win2019"

 

You may need to use the Task Scheduler instead, to make it work.

Or try placing a shortcut of the script as a startup program in %APPDATA%\Microsoft\Windows\Start Menu\Programs\Startup.

Or place a shortcut to your start script in folder C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp – that make the script run when user login.

 

More Information:

https://askubuntu.com/questions/457329/shutting-down-all-virtualbox-vagrant-vms-in-one-easy-to-use-bash-command-that  

https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2012-r2-and-2012/dn789196(v=ws.11)

https://simplecodesoftware.com/articles/how-to-set-up-group-policy-scripts-programmatically

Vboxmanage command not found in Windows CMD or PowerShell

https://www.windowscentral.com/how-create-automated-task-using-task-scheduler-windows-10

https://4sysops.com/archives/managing-virtualbox-vms-with-powershell/

http://desertpenguin.org/blog/nnvirtualboxpowershellmodul.html

https://github.com/SmithersTheOracle/VirtualBoxPS

Managing VirtualBox with PowerShell