VirtualBox 5.1.22 silent uninstall

This will:
  • Uninstall VirtualBox on 64-bit or 32-bit Windows
  • Uninstall any version of VirtualBox 5
  • Uninstall applcation no matter in what custom directory it is installed
Here is the code:
@echo off
set sw=HKLM\SOFTWARE
set u=Microsoft\Windows\CurrentVersion\Uninstall
set n=Oracle VM VirtualBox
setlocal EnableDelayedExpansion
for /f "tokens=7 delims=\" %%a in ('^
reg query "%sw%\%u%" /s ^| find "\Uninstall\"') do (
reg query "%sw%\%u%\%%a" /v DisplayName > nul 2>&1
if !errorlevel!==0 (
reg query "%sw%\%u%\%%a" /v DisplayName | findstr "%n%"
if !errorlevel!==0 (
echo %n% found
echo %%a | find "{"
if !errorlevel!==0 %systemroot%\system32\msiexec.exe /X %%a /qn
)
)
)
endlocal
This is tested on:
http://download.virtualbox.org/virtualbox/5.1.22/VirtualBox-5.1.22-115126-Win.exe
5918f1e7274412b81e88d40005c0c3c3
766fbc1858ca6ae3790d1843ee1f7edea4a85024

No comments: