Created
June 19, 2016 05:34
-
-
Save oscarkuo/981da097c2c82215bbbd28ae31864389 to your computer and use it in GitHub Desktop.
This file contains 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 | |
set cassie_running=0 | |
set creeper_running=0 | |
set roguecode_running=0 | |
call:stopVmIfItIsRunning "roguecode" roguecode_running | |
call:stopVmIfItIsRunning "creeper" creeper_running | |
call:stopVmIfItIsRunning "cassie" cassie_running | |
robocopy /mir "C:\Users\Oscar\VirtualBox VMs" Y:\z14\virtualbox | |
call:restartVmIfItWasRunning "roguecode" %roguecode_running% | |
call:restartVmIfItWasRunning "cassie" %cassie_running% | |
call:restartVmIfItWasRunning "creeper" %creeper_running% | |
:stopVmIfItIsRunning | |
"c:\Program Files\Oracle\VirtualBox\VBoxManage.exe" list runningvms | find /i "%~1" | |
if not %errorlevel% equ 1 ( | |
echo "%~1" is running | |
set "%~2=1" | |
echo "saving state - %~1" | |
"c:\Program Files\Oracle\VirtualBox\VBoxManage.exe" controlvm "%~1" savestate | |
) | |
goto:eof | |
:restartVmIfItWasRunning | |
echo "%~1 was running => %~2" | |
if %~2 equ 1 ( | |
echo "starting - %~1" | |
"c:\Program Files\Oracle\VirtualBox\VBoxManage.exe" startvm "%~1" --type headless | |
) | |
goto:eof |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment