25
25
:# Pause before exiting after an error, to give time to #
26
26
:# read the error message from within ag_setup.exe. #
27
27
:# 2021-11-14 JFL Added option -y. #
28
+ :# Fixed the registry update from within ag_setup.exe. #
28
29
:# #
29
30
:##############################################################################
30
31
@@ -628,7 +629,14 @@ set "INSTALLED_FILES=!INSTALLED_FILES:~1!" &:# Remove the initial space
628
629
629
630
:# Write the uninstall information into the registry
630
631
:# This is used by winget.exe to locate previous installations.
631
- %COMMENT% Writing uninstall information into the registry
632
+ %COMMENT% Writing uninstall information into the registry key:
633
+ %COMMENT% !UNINSTALL_KEY!
634
+ set " REGEDIT = regedit.exe"
635
+ :# Gotcha: When running in a 32-bits shell within ag_setup.exe, regedit.exe
636
+ :# runs the 32-bits version, which silently accesses a different registry key:
637
+ :# HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall
638
+ :# In this case, make sure to use the 64-bits version of regedit.exe:
639
+ for %%r in (%WINDIR% \sysnative\regedt32.exe) do if exist %%r set " REGEDIT = %%r "
632
640
call :SplitVer %NEW_AG_VER% V_MAJOR V_MINOR V_PATCH V_BUILD
633
641
set QUOTED_KEY = " !UNINSTALL_KEY! "
634
642
set " UNINSTALL_STRING = %windir% \System32\cmd.exe /c del !INSTALLED_FILES! & reg delete !QUOTED_KEY! /f"
@@ -649,7 +657,7 @@ echo "VersionMinor"="%V_MINOR%"
649
657
) > " %TEMP% \ag_setup.reg"
650
658
%LOG% type " %TEMP% \ag_setup.reg"
651
659
>> " %LOGFILE% " type " %TEMP% \ag_setup.reg"
652
- %EXEC% regedit.exe /s " %TEMP% \ag_setup.reg"
660
+ %EXEC% %REGEDIT% /s " %TEMP% \ag_setup.reg"
653
661
if errorlevel 1 (
654
662
%ERROR% Failed to import the uninstall information into the registry
655
663
%PAUSE%
0 commit comments