Skip to content

Instantly share code, notes, and snippets.

@jfollmann
Last active December 19, 2018 11:07
Show Gist options
  • Save jfollmann/9f339c3cd30e4e1a72cbc3a3b82d6a1f to your computer and use it in GitHub Desktop.
Save jfollmann/9f339c3cd30e4e1a72cbc3a3b82d6a1f to your computer and use it in GitHub Desktop.
VirtualBox commands
@echo off
set curdir=%cd%
set VM_NAME="Ubuntu Server"
c:
cd\
cd Program Files\Oracle\VirtualBox
:loop
if "%1"=="" goto :done
if "%1"=="-list" goto :list
if "%1"=="-status" goto :status
if "%1"=="-start" goto :start
if "%1"=="-stop" goto :stop
if "%1"=="-ip" goto :ip
if "%1"=="-help" goto :help
shift
goto :loop
:ip
VBoxManage guestproperty enumerate %VM_NAME% | findstr /c:"/VirtualBox/GuestInfo/Net/0/V4/IP"
goto done
:list
VBoxManage list vms
goto done
:start
VBoxManage startvm %VM_NAME% --type headless
goto :done
:stop
VBoxManage controlvm %VM_NAME% poweroff
goto :done
:status
VBoxManage showvminfo %VM_NAME% | findstr /c:"State"
goto :done
:help
echo --- Help ---
echo use manage-vm.bat -stop
echo use manage-vm.bat -start
echo use manage-vm.bat -list
echo use manage-vm.bat -status
echo use manage-vm.bat -ip
:done
echo Done.
cd /d %curdir%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment