Last active
May 25, 2017 15:06
-
-
Save Phuseos/53b450d20e0a638e2f6693f1063364b2 to your computer and use it in GitHub Desktop.
Run headless virtual machine using VirtualBox
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 | |
:: Navigate to the default VirtualBox install directory | |
C: | |
cd C:\Program Files\Oracle\VirtualBox | |
:: Run the VM Headless | |
start /wait VBoxManage.exe startvm "YourVMName" | |
:: The loop, find the task, keep looping until a not found error is thrown | |
:LOOP | |
tasklist | find /i "VirtualBox" >nul 2>&1 | |
IF ERRORLEVEL 1 ( | |
:: VirtualBox process not found, exit loop | |
GOTO EXIT | |
) ELSE ( | |
:: Virtual Machine Is still running | |
Timeout /T 5 /Nobreak | |
GOTO LOOP | |
) | |
:: Task is no longer found, keep the console open for feedback | |
:EXIT | |
PAUSE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment