Put bluntly I'm new to batch. I have little to no experience with it and I have been tasked with helping to automate the upgrade/uninstall process for Java.
The script below is a modified version of one found here (https://stackoverflow.com/questions/332 ... 3#33279973), which initially worked as intended.
Code: Select all
@echo off setlocal enableDelayedExpansion for /f "delims=" %%b in (' reg query HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall ^ /s /d /f "Java" ^| findstr "HKEY_ DisplayName" ') do ( set "line=%%b" if "!line:~0,4!"=="HKEY" ( set "key=!line!" ) else ( set Uninstall= rem Sort /r makes QuietUninstallString the last line for /f "tokens=2*" %%c in (' reg query "!key!" ^| find "UninstallString" ^| sort /r ') do if not "%%d"=="" set "Uninstall=%%d" if defined Uninstall ( for /f "tokens=2*" %%c in ("!line!") do echo Found %%d echo Running !Uninstall! (COMMENTED FOR TESTING) rem call !Uninstall! echo. ) ) ) pause
My thought process to achieve this is to add another |findstr, searching the InstallLocation part of the key for "D:\" - I have attempted to implement this with minor success. Help achieving this would be appreciated.