Skip to content

Instantly share code, notes, and snippets.

Created August 24, 2017 13:49
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save mkorthof/deef752e03305a16e46f0e179b036820 to your computer and use it in GitHub Desktop.
VirtualBox savestate all running VM's (Windows)
@echo off
SET "LOGFILE=%~dp0%vboxsave.log"
SET VBoxManage="%ProgramFiles%\Oracle\VirtualBox\VBoxManage.exe"
IF "%~1"=="LOG" ( SET "LOG=1" )
IF EXIST "%LOGFILE%.tmp" ( del %LOGFILE%.tmp )
IF %LOG% EQU 1 ( CALL :msg logging is enabled )
CALL :msg starting %VBoxManage% list runningvms...
FOR /F tokens^=2^,4^ delims^=^" %%p IN ('%VBoxManage% list runningvms') DO (
CALL :msg running controlvm %%p savestate:
%VBoxManage% controlvm %%p savestate >%LOGFILE%.tmp 2>&1
type %LOGFILE%.tmp
IF %LOG% EQU 1 ( type %LOGFILE%.tmp >> %LOGFILE% )
del %LOGFILE%.tmp
CALL :msg done
FOR /f "delims=" %%# IN ('powershell.exe Get-Date -Format G') do @set cdate=%%#
echo %cdate% %*
IF %LOG% EQU 1 ( echo %cdate% %* >> %LOGFILE% )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment