卸载程序不删除注册表

时间:2011-12-20 07:08:27

标签: registry nsis uninstall

Function Check32or64BitWindows
${If} ${RunningX64}
      strcpy $INSTDIR "$PROGRAMFILES64\${APP_FULL_PATH}" 
      SetRegView 64

${Else}
       SetRegView 32
       strcpy $INSTDIR "$PROGRAMFILES32\${APP_FULL_PATH}"
${EndIf}
FunctionEnd

如果检测到旧版本,则执行

ExecWait '"$INSTDIR\uninst.exe" /S' $0

我的卸载部分:

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部分在windows 64bit注册表视图中创建注册表项,但卸载程序不会删除注册表项。

如果我删除64位操作系统的检查,那么在Wow6432Node中创建和删除注册表就可以正常工作。

2 个答案:

答案 0 :(得分:6)

如果您不安装x64应用程序,则根本不应使用SetRegView / $ PROGRAMFILES64。

如果您要安装x64应用程序并且在安装期间调用了SetRegView 64,则还必须在卸载程序中调用SetRegView 64

使用Process Monitor调查其他注册管理机构问题......

答案 1 :(得分:1)

我发现NSIS教程将64位安装程序逻辑放在函数.onInit中,安装开始时会自动调用该函数。

逻辑上,人们会尝试通过Call .onInit在卸载部分手动调用此方法,但NSIS编译将失败,因为函数名称不以un.开头。

所以,从逻辑上讲,如果你创建一个un.onInit,它应该“正常工作”。确实如此。

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

...如果您想知道“为什么要创建重复的功能?”,那么问题的正确答案是here ......