uninstaller not deleting registry
Asked Answered
P

2

5
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.

Pickerelweed answered 20/12, 2011 at 7:8 Comment(3)
Are you installing a x64 application?Capwell
Please be more careful with your formatting. You get a preview as you work and a toolbar which can help with most of the formatting. I've fixed it mostly, but it still needs work.Enterprise
And I'd hope that an uninstaller wouldn't delete the registry ;-)Enterprise
C
9

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...

Capwell answered 20/12, 2011 at 8:26 Comment(0)
W
5

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...

Wraparound answered 28/5, 2015 at 2:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.