only x86 exe, static registry key
UninstallString with quotes

This method applies to 4K Video Downloader, ActivePresenter, KeePass, Win32DiskImager, ImgBurn, GanttProject

silent-install.cmd
@echo off
setlocal EnableDelayedExpansion
set sw=HKLM\SOFTWARE
set u=Microsoft\Windows\CurrentVersion\Uninstall
set k=KeePassPasswordSafe2_is1
set n=KeePass 2
if not "%ProgramFiles(x86)%"=="" set x=Wow6432Node\
reg query "%sw%\%x%%u%\%k%" > nul 2>&1
if not !errorlevel!==0 (
for /f "tokens=*" %%a in ('dir /b "%~dp0KeePass*.exe"') do (
echo %n%
start /wait "" "%~dp0%%a" /SILENT
)
) else echo %n% already installed!
endlocal
silent-uninstall.cmd
@echo off
set sw=HKLM\SOFTWARE
set u=Microsoft\Windows\CurrentVersion\Uninstall
set k=KeePassPasswordSafe2_is1
if not "%ProgramFiles(x86)%"=="" set x=Wow6432Node\
for /f delims^=^"^ tokens^=2 %%a in ('^
reg query "%sw%\%x%%u%\%k%" /v UninstallString ^|
find "UninstallString"') do (
start /wait "" "%%a" /SILENT
)

No comments: