Upgrade existing KeePass 2 version to 2.36

CatOnRug solve, automate, speed up Upgrade existing KeePass 2 version to 2.36
This will:
  • update KeePass to version to 2.36
  • skip the installation if no KeePass was found

KeePass 2.36 has new feature:

To work with this silent updrade method I need additional libraries:
libiconv2.dll | libintl3.dll | regex2.dll | sed.exe

The installer:
http://sourceforge.net/projects/keepass/files/KeePass%202.x/2.36/KeePass-2.36-Setup.exe/download
6d1894d8ae39101322ff041c682ae193
5cecfa817642ea40a84e70ef6c7822a41b7aeb77

Upgrade script upgrade.cmd
@echo off
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\
setlocal EnableDelayedExpansion



rem read the version number of KeePass-2.XX-Setup.exe
for /f "tokens=*" %%v in ('dir /b "%~dp0KeePass*.exe" ^|sed "s/-/\n/g" ^| grep -v "[a-zA-Z]"') do (

rem check if keepass is installed
reg query "%sw%\%x%%u%\%k%" > nul 2>&1
if !errorlevel!==0 (

rem look which exact version is installed
reg query "%sw%\%x%%u%\%k%" /v DisplayVersion | findstr "%%v" > nul 2>&1
rem if not ok the execute latest installer
if not !errorlevel!==0 for /f "tokens=*" %%a in ('dir /b "%~dp0KeePass*.exe"') do (
echo found old version:
reg query "%sw%\%x%%u%\%k%" /v DisplayVersion | findstr "DisplayVersion"
echo.

tasklist | findstr "KeePass.exe" > nul 2>&1
if not !errorlevel!==0 (
echo updating..
start /wait "" "%~dp0%%a" /SILENT
) else echo Can not update. KeePass.exe instance already running
echo.

)

echo version installed now:
reg query "%sw%\%x%%u%\%k%" /v DisplayVersion | findstr "DisplayVersion"
echo.

) else echo %n% not installed at all

)


endlocal
pause

No comments:

Post a Comment