native exe, dynamic registry key
msiexec uninstall

This method applies to VirtualBox

silent-install.cmd
@echo off
set sw=HKLM\SOFTWARE
set u=Microsoft\Windows\CurrentVersion\Uninstall
set n=Oracle VM VirtualBox
setlocal EnableDelayedExpansion

:detect64
if "%ProgramFiles(x86)%"=="" goto native

:x64
reg query "%sw%\Wow6432Node\%u%" /s | find "%n%"
if !errorlevel!==0 goto exist

:native
reg query "%sw%\%u%" /s | find "%n%"
if !errorlevel!==0 goto exist

:install

for /f "tokens=*" %%a in ('dir /b "%~dp0VirtualBox*.exe"') do (
echo %n%
start /wait "" "%~dp0%%a" --silent
rem disable updates
"%programfiles%\Oracle\VirtualBox\VBoxManage.exe" setextradata global GUI/UpdateDate "never"
rem disable ballon tips
"%programfiles%\Oracle\VirtualBox\VBoxManage.exe" setextradata global GUI/SuppressMessages "all"
)

:exist
endlocal
silent-uninstall.cmd
@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 | find "%n%" > nul 2>&1
if !errorlevel!==0 (
echo %n% | find "{"
if !errorlevel!==0 %systemroot%\system32\msiexec.exe /X %%a /qn
)
)
)
endlocal
Check out more from