Вопрос

I created an window application for which I need to create setup.For creating setup i am using NSIS. I had written script to create setup file I need to link this setup file to Add/remove program. For add link to add/remove program I am using following code:

   WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\app" "DisplayName" "Name"
   WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\app" "AppName" '"$INSTDIR\UninstallApp.exe"'

This code successfully add the details in registry Software\Microsoft\Windows\CurrentVersion\Uninstall\app but not able to add link to add/remove.

Это было полезно?

Решение

Did you try HKLM with ADMIN rights? i.e. Launch your installer with administrative privileges.

Code snipped should look like this

!include "MUI2.nsh"

!define PRODUCT_NAME             "MyProduct"
!define PRODUCT_UNINST_REGKEY    "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
!define PRODUCT_DEF_LOC          "$PROGRAMFILES\${PRODUCT_NAME}"
!define PRODUCT_UNINSTALLER      "MyUninstaller.exe"

!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES

!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES

!insertmacro MUI_LANGUAGE "English"

Name         "${PRODUCT_NAME} Test"
OutFile      "${PRODUCT_NAME}_Setup.exe"
InstallDir   "${PRODUCT_DEF_LOC}"


Section "Core section" SecCore

    SetOutPath $INSTDIR

    WriteRegExpandStr HKLM "${PRODUCT_UNINST_REGKEY}" "UninstallString" "$INSTDIR\${PRODUCT_UNINSTALLER}"
    WriteRegStr       HKLM "${PRODUCT_UNINST_REGKEY}" "DisplayName"     "Name"

    WriteUninstaller  "$INSTDIR\${PRODUCT_UNINSTALLER}"

SectionEnd



Section "Uninstall"
    Delete "$INSTDIR\${PRODUCT_UNINSTALLER}"
    RMDir  $INSTDIR
    DeleteRegKey HKLM "${PRODUCT_UNINST_REGKEY}"
SectionEnd

Другие советы

According to the official documentation, the hive HKCU is only supported for NT4/2000/XP for the current user.

Try to use the HKLM instead.

There are two required uninstall string entries and they are DisplayName and UninstallString.

The other entries like URLInfoAbout are optional but the two required entries must be present to show the item in the first place.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top