From dfc7143b8ee4d1366e053b7a97cf582214deb377 Mon Sep 17 00:00:00 2001 From: "Vladimir.Orlov" Date: Tue, 17 Nov 2015 15:07:40 +0300 Subject: [PATCH] IDEA-147538 Uninstalling doesn't remove program from 'Programs and features' list in Control Panel --- build/conf/nsis/idea.nsi | 73 +++++++++++++++++++++--------------- build/conf/nsis/registry.nsi | 46 +++++++++++++++++------ 2 files changed, 76 insertions(+), 43 deletions(-) diff --git a/build/conf/nsis/idea.nsi b/build/conf/nsis/idea.nsi index 73c5c50deb06..f6ca71196528 100644 --- a/build/conf/nsis/idea.nsi +++ b/build/conf/nsis/idea.nsi @@ -909,11 +909,32 @@ FunctionEnd ; custom uninstall functions ;------------------------------------------------------------------------------ -Function un.onInit +Function un.getRegKey + ReadRegStr $R2 HKCU "Software\${MANUFACTURER}\${PRODUCT_REG_VER}" "" + StrCpy $R2 "$R2\bin" +user: + StrCmp $R2 $INSTDIR HKCU admin +HKCU: StrCpy $baseRegKey "HKCU" + goto Done +admin: + ReadRegStr $R2 HKLM "Software\${MANUFACTURER}\${PRODUCT_REG_VER}" "" + StrCpy $R2 "$R2\bin" + StrCmp $R2 $INSTDIR HKLM cant_find_installation +HKLM: + StrCpy $baseRegKey "HKLM" + goto Done +cant_find_installation: ;admin perm. is required to uninstall? ${UnStrStr} $R0 $INSTDIR $PROGRAMFILES - StrCmp $R0 $INSTDIR requred_admin_perm UAC_Done + StrCmp $R0 $INSTDIR HKLM HKCU +Done: +FunctionEnd + + +Function un.onInit + Call un.getRegKey + StrCmp $baseRegKey "HKLM" requred_admin_perm UAC_Done requred_admin_perm: ;the user has admin rights? @@ -1116,18 +1137,12 @@ skip_delete_settings: ${EndIf} ReadRegStr $R9 HKCU "Software\${MANUFACTURER}\${PRODUCT_REG_VER}" "MenuFolder" - StrCmp $R9 "" "" clear_shortcuts + StrCmp $R9 "" "" shortcuts ReadRegStr $R9 HKLM "Software\${MANUFACTURER}\${PRODUCT_REG_VER}" "MenuFolder" - StrCmp $R9 "" clear_registry + StrCmp $R9 "" registry StrCpy $5 "Software\${MANUFACTURER}" -; call un.winVersion -; ${If} $0 == "1" -; StrCpy $5 "Software\Wow6432Node\${MANUFACTURER}" -; ${EndIf} -clear_shortcuts: +shortcuts: ;the user has the admin rights -; UserInfo::GetAccountType -; Pop $R2 IfFileExists "$DESKTOP\${PRODUCT_FULL_NAME_WITH_VER}.lnk" keep_current_user SetShellVarContext all keep_current_user: @@ -1141,18 +1156,8 @@ keep_current_user: Delete "$DESKTOP\${PRODUCT_FULL_NAME_WITH_VER}.lnk" Delete "$QUICKLAUNCH\${PRODUCT_FULL_NAME_WITH_VER}.lnk" -clear_registry: +registry: StrCpy $5 "Software\${MANUFACTURER}" - call un.winVersion - ${If} $0 == "1" - StrCpy $5 "Software\Wow6432Node\${MANUFACTURER}" - ${EndIf} - - StrCpy $0 $baseRegKey - StrCpy $1 "$5\${PRODUCT_REG_VER}" - StrCpy $2 "MenuFolder" - Call un.OMDeleteRegValue - StrCmp "${ASSOCIATION}" "NoAssociation" finish_uninstall push "${ASSOCIATION}" loop: @@ -1166,25 +1171,29 @@ loop: finish_uninstall: StrCpy $0 $baseRegKey StrCpy $1 "$5\${PRODUCT_REG_VER}" - StrCpy $2 "Build" - Call un.OMReadRegStr + StrCpy $4 0 + +getValue: + Call un.OMEnumRegValue + IfErrors finish delValue +delValue: + StrCpy $2 $3 + Call un.OMDeleteRegValue + IfErrors 0 +2 + IntOp $4 $4 + 1 + goto getValue +finish: StrCpy $1 "$5\${PRODUCT_REG_VER}" - Call un.OMDeleteRegKey - - StrCpy $1 "$5\${MUI_PRODUCT}" Call un.OMDeleteRegKeyIfEmpty - StrCpy $1 "$5" Call un.OMDeleteRegKeyIfEmpty StrCpy $0 "HKCR" StrCpy $1 "Applications\${PRODUCT_EXE_FILE}" - StrCpy $2 "" Call un.OMDeleteRegKey StrCpy $0 "HKCR" StrCpy $1 "${PRODUCT_PATHS_SELECTOR}" - StrCpy $2 "" Call un.OMDeleteRegKey StrCpy $0 "HKCR" @@ -1196,7 +1205,9 @@ remove_IntelliJIdeaProjectFile: StrCpy $1 "IntelliJIdeaProjectFile" Call un.OMDeleteRegKey done: - DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_WITH_VER}" + StrCpy $0 $baseRegKey + StrCpy $1 "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_WITH_VER}" + Call un.OMDeleteRegKey ;do not show feedback web page checkbox for EAP builds. StrCmp "${PRODUCT_WITH_VER}" "${MUI_PRODUCT} ${VER_BUILD}" end_of_uninstall feedback_web_page feedback_web_page: diff --git a/build/conf/nsis/registry.nsi b/build/conf/nsis/registry.nsi index 79bf61f8e307..baff6702852a 100644 --- a/build/conf/nsis/registry.nsi +++ b/build/conf/nsis/registry.nsi @@ -10,11 +10,11 @@ Function ${un}OMDeleteRegKey StrCmp $0 "HKLM" hklm StrCmp $0 "HKCR" hkcr hkcu: - DeleteRegKey HKCU $1 - goto done + DeleteRegKey HKCU $1 + goto done hklm: DeleteRegKey HKLM $1 - goto done + goto done hkcr: DeleteRegKey HKCR $1 done: @@ -87,7 +87,7 @@ FunctionEnd ; OMEnumRegKey ; $0 - root_key ("HKCU" | "HKLM" | "HKCR") ; $1 - subkey -; $4 - value name +; $4 - index ; $3 - result Function ${un}OMEnumRegKey ClearErrors @@ -95,16 +95,38 @@ Function ${un}OMEnumRegKey StrCmp $0 "HKLM" hklm StrCmp $0 "HKCR" hkcr hkcu: - EnumRegKey $3 HKCU $1 $4 - goto done + EnumRegKey $3 HKCU $1 $4 + goto done hklm: - EnumRegKey $3 HKLM $1 $4 + EnumRegKey $3 HKLM $1 $4 goto done hkcr: EnumRegKey $3 HKCR $1 $4 done: FunctionEnd +; ----------------------------------------------------------------------------- +; OMEnumRegValue +; $0 - root_key ("HKCU" | "HKLM" | "HKCR") +; $1 - subkey +; $4 - index +; $3 - result +Function ${un}OMEnumRegValue + ClearErrors + StrCmp $0 "HKCU" hkcu + StrCmp $0 "HKLM" hklm + StrCmp $0 "HKCR" hkcr + hkcu: + EnumRegValue $3 HKCU $1 $4 + goto done + hklm: + EnumRegValue $3 HKLM $1 $4 + goto done + hkcr: + EnumRegValue $3 HKCR $1 $4 +done: +FunctionEnd + ; ----------------------------------------------------------------------------- ; OMWriteRegStr ; $0 - root_key ("HKCU" | "HKLM" | "HKCR") @@ -117,13 +139,13 @@ Function ${un}OMWriteRegStr StrCmp $0 "HKLM" hklm StrCmp $0 "HKCR" hkcr hkcu: - WriteRegStr HKCU $1 $2 $3 - goto done + WriteRegStr HKCU $1 $2 $3 + goto done hklm: - WriteRegStr HKLM $1 $2 $3 - goto done + WriteRegStr HKLM $1 $2 $3 + goto done hkcr: - WriteRegStr HKCR $1 $2 $3 + WriteRegStr HKCR $1 $2 $3 done: FunctionEnd