Skip to content

Commit 686b2a5

Browse files
committed
Fixed the registry update from within ag_setup.exe
1 parent bb844fe commit 686b2a5

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

win32/winget/setup.bat

+10-2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
:# Pause before exiting after an error, to give time to #
2626
:# read the error message from within ag_setup.exe. #
2727
:# 2021-11-14 JFL Added option -y. #
28+
:# Fixed the registry update from within ag_setup.exe. #
2829
:# #
2930
:##############################################################################
3031

@@ -628,7 +629,14 @@ set "INSTALLED_FILES=!INSTALLED_FILES:~1!" &:# Remove the initial space
628629

629630
:# Write the uninstall information into the registry
630631
:# 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"
632640
call :SplitVer %NEW_AG_VER% V_MAJOR V_MINOR V_PATCH V_BUILD
633641
set QUOTED_KEY="!UNINSTALL_KEY!"
634642
set "UNINSTALL_STRING=%windir%\System32\cmd.exe /c del !INSTALLED_FILES! & reg delete !QUOTED_KEY! /f"
@@ -649,7 +657,7 @@ echo "VersionMinor"="%V_MINOR%"
649657
) >"%TEMP%\ag_setup.reg"
650658
%LOG% type "%TEMP%\ag_setup.reg"
651659
>>"%LOGFILE%" type "%TEMP%\ag_setup.reg"
652-
%EXEC% regedit.exe /s "%TEMP%\ag_setup.reg"
660+
%EXEC% %REGEDIT% /s "%TEMP%\ag_setup.reg"
653661
if errorlevel 1 (
654662
%ERROR% Failed to import the uninstall information into the registry
655663
%PAUSE%

0 commit comments

Comments
 (0)