Skip to content

Instantly share code, notes, and snippets.

@dogi
Created August 31, 2016 19:37
Show Gist options
  • Save dogi/2c0364b95997e74acf28b9537fedf092 to your computer and use it in GitHub Desktop.
Save dogi/2c0364b95997e74acf28b9537fedf092 to your computer and use it in GitHub Desktop.
ECHO off
::Halts and Destroys ALL machines
cd "C:\Users\%USERNAME%\ole--vagrant-community\windows"
cd /d %~dp0
for /f "skip=2 tokens=1 delims= " %%F IN ('vagrant global-status') DO (
vagrant halt "%%F"
vagrant destroy -f "%%F"
)
::Get Admin For Batch File
REM --> Check for permissions
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
REM --> If error flag set, we do not have admin.
if '%errorlevel%' NEQ '0' (
echo Requesting administrative privileges...
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
set params = %*:"=""
echo UAC.ShellExecute "cmd.exe", "/c %~s0 %params%", "", "runas", 1 >> "%temp%\getadmin.vbs"
"%temp%\getadmin.vbs"
del "%temp%\getadmin.vbs"
exit /B
)
pushd "%CD%"
CD /D "%~dp0"
::Uninstalls Vagrant
wmic product where name="Vagrant" call uninstall
::Uninstalls VirtualBox
wmic product where name="Oracle VM VirtualBox 5.1.4" call uninstall
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment