Skip to content

Instantly share code, notes, and snippets.

@poloniusDergath
Created May 22, 2018 15:47
Show Gist options
  • Select an option

  • Save poloniusDergath/fac68341b2c7cc7b495ce7749cecaab5 to your computer and use it in GitHub Desktop.

Select an option

Save poloniusDergath/fac68341b2c7cc7b495ce7749cecaab5 to your computer and use it in GitHub Desktop.
CMD script to stop running VirtualBox machine
@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION
set VBOX_HOME=C:\PROGRA~1\Oracle\VirtualBox
set _VM=%VM_NAME%
%VBOX_HOME%\VBoxManage.exe controlvm %_VM% acpipowerbutton
set _wait=VM stopping, please wait
set _punto=.
set _count=0
:loop
cls
set _wait=!_wait!%_punto%
echo %_wait%
timeout /t 1 > NUL
set /a "_count+=1"
%VBOX_HOME%\VBoxManage.exe showvminfo %_VM% | findstr /b /c:"State:" | findstr /c:"running" > NUL
if errorlevel 1 exit /B
if %_count% LSS 60 (goto loop) else (echo. Machine still running...)
pause
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment