Skip to content

Instantly share code, notes, and snippets.

@Phuseos
Last active May 25, 2017 15:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Phuseos/53b450d20e0a638e2f6693f1063364b2 to your computer and use it in GitHub Desktop.
Save Phuseos/53b450d20e0a638e2f6693f1063364b2 to your computer and use it in GitHub Desktop.
Run headless virtual machine using VirtualBox
@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