Created
May 22, 2018 15:47
-
-
Save poloniusDergath/fac68341b2c7cc7b495ce7749cecaab5 to your computer and use it in GitHub Desktop.
CMD script to stop running VirtualBox machine
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @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