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:
- In a command window, open the Group Policy Editor (GPE) by running gpedit.msc.
- Expand Computer Configuration and select Windows Settings.
- Double-click Scripts (Startup/Shutdown).
- 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://simplecodesoftware.com/articles/how-to-set-up-group-policy-scripts-programmatically
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