Reputation: 309
Function Check32or64BitWindows
${If} ${RunningX64}
strcpy $INSTDIR "$PROGRAMFILES64\${APP_FULL_PATH}"
SetRegView 64
${Else}
SetRegView 32
strcpy $INSTDIR "$PROGRAMFILES32\${APP_FULL_PATH}"
${EndIf}
FunctionEnd
If an older version is detected then I execute
ExecWait '"$INSTDIR\uninst.exe" /S' $0
My uninstall section:
Section uninstall
!define APP_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_VENDOR} ${APP_NAME}"
!define APP_UNINST_ROOT_KEY "HKLM"
DeleteRegKey ${APP_UNINST_ROOT_KEY} "${APP_UNINST_KEY}"
SectionEnd
Section -Post
WriteRegStr ${APP_UNINST_ROOT_KEY} "${APP_UNINST_KEY}" "DisplayName" "${APP_FULL_NAME}"
SectionEnd
Post section creates the registry entry in the windows 64bit registry view but uninstaller is not deleting the registry entry.
If I remove the check for 64bit OS, then creation and deletion of registry in Wow6432Node works correctly.
Upvotes: 5
Views: 5573
Reputation: 7922
The NSIS tutorials I've found place the 64-bit installer logic in a function .onInit
which is called automatically when the install starts.
Logically, one would try to call this manually in the uninstall section via Call .onInit
, but NSIS compilation will fail because the function name doesn't start with un.
.
So, logically, if you create an un.onInit
, it should "Just work". And it does.
Function un.onInit
${If} ${RunningX64}
; Comment out this next line in production environment
MessageBox MB_OK "This is a 64-bit os, applying work-arounds"
SetRegView 64
StrCpy $INSTDIR "$PROGRAMFILES64\My FooBar Application"
${EndIf}
FunctionEnd
... and if you are wondering "Why create a duplicate function?", the proper answer to that question is here...
Upvotes: 5
Reputation: 101606
If you are not installing a x64 application you should not use SetRegView/$PROGRAMFILES64 at all.
If you are installing a x64 application and you called SetRegView 64
during install you also have to call SetRegView 64
in the uninstaller.
Use Process Monitor to investigate other registry issues...
Upvotes: 10