I’m creating an installer for an Excel Add-In.
The install adds a value to the Excel Registry tree at:
HKCUSOFTWAREMicrosoftOffice16.0ExcelAdd-in Manager
With is simply the path to the add in, which in turn tells Excel to load it on the add-in list.
When the add in is actually loaded, that is, when the checkmark by the add-in entry is checked and the uses clicks close, Excel deletes that entry and creates one in:
HKCUSOFTWAREMicrosoftOffice16.0ExcelOptionsOPEN
Whose value is the path to the add-in.
However, if we have one or more add-ins installed the OPEN
can be OPEN1
, OPEN2
, or whatever number of add-ins have been loaded by the user.
In my NSI file, I wrote the following code on the uninstall:
; Iterates through the registry and unregisters the Add-In from Excel
; set variable $0 to 0
StrCpy $0 0
; loop through the registry
loop:
LogText "Checking registry key: SOFTWAREMicrosoftOffice16.0ExcelOptions -> OPEN$0"
; read the registry key. Add $0 if $0 != 0
${If} $0 == 0
ReadRegStr $1 HKCU "SOFTWAREMicrosoftOffice16.0ExcelOptions" "OPEN"
${Else}
ReadRegStr $1 HKCU "SOFTWAREMicrosoftOffice16.0ExcelOptions" "OPEN$0"
${EndIf}
; check if the registry key is empty
; if it is empty, leave the loop
${if} $1 == ""
LogText "Registry key is empty. Exiting loop."
Goto end
${EndIf}
LogText "Registry value: '$1'"
; check if the registry key contains the path to the Add-In
${If} $1 != "$INSTDIRMyAddIn.xlam"
LogText "Not our Add-In. Skipping..."
Goto next
${Else}
${If} $0 == 0
LogText "Removing registry key: SOFTWAREMicrosoftOffice16.0ExcelOptions -> OPEN"
DeleteRegValue HKCU "SOFTWAREMicrosoftOffice16.0ExcelOptions" "OPEN"
${Else}
LogText "Removing registry key: SOFTWAREMicrosoftOffice16.0ExcelOptions -> OPEN$0"
DeleteRegValue HKCU "SOFTWAREMicrosoftOffice16.0ExcelOptions" "OPEN$0"
${EndIf}
Goto end
${EndIf}
next:
; increment the variable $0
IntOp $0 $0 + 1
; go back to the beginning of the loop
Goto loop
end:
Even though I added the LogText
, there is nothing on the log file (install.log
on the root of C:
) about the uninstall.
Am I doing something wrong here?