Not able to embed link in add/remove program - nsis

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.

Related

Knowing in a Section if another Section has already been executed

I want to create a Suite installer for the various application we develop. The structure is as follows:
Application A
Requires no driver installation
Application B
Requires driver 1 and 2
Application C
Requires driver 2 and 3
The user has the option to install any application he wants, or multiple. I know how to use Sections for this. This will work fine if the user selects only Application A, or Application A with either B or C. However, if the user selects Application B and C, I would like to avoid that driver 2 will be prompted to install twice.
Is there a way to achieve this? For instance, is it possible to know when the section for Application C is executed, that the section for Application B has already been executed, and that driver 2 does not need to be installed again?
There are probably many ways to handle this, one is to put the driver in a hidden section that you make sure is in the correct state:
!include LogicLib.nsh
!include Sections.nsh
!include x64.nsh
Page Components
Page Directory
Page InstFiles
Section "-Driver2" SID_DRIVER2
${If} ${IsNativeAMD64}
; Install AMD64 64-bit driver/library
${ElseIf} ${IsNativeARM64}
; Install ARM64 64-bit driver/library
${ElseIf} ${IsNativeIA32}
; Install i386 32-bit driver/library
${Else}
Abort "Unsupported CPU architecture!"
${EndIf}
SectionEnd
Section "App B" SID_APPB
SectionEnd
Section /o "App C" SID_APPC
SectionEnd
Function .onSelChange
${If} ${SectionIsSelected} ${SID_APPB}
${OrIf} ${SectionIsSelected} ${SID_APPC}
!insertmacro SelectSection ${SID_DRIVER2}
${Else}
!insertmacro UnselectSection ${SID_DRIVER2}
${EndIf}
FunctionEnd
Function .onInit
Call .onSelChange ; Make sure things are configured correctly in silent installers
FunctionEnd

NSIS MUI_UNPAGE_WELCOME custom info text

How to override info text on uninstaller welcome page (MUI_UNPAGE_WELCOME)?
I used MUI_TEXT_WELCOME_INFO_TEXT for installer welcome page. But I cannot find solution for uninstaller.
MUI_TEXT_WELCOME_INFO_TEXT is not documented as something you can set.
The MUI documentation tells you which defines you can set and where they apply:
Page settings apply to a single page and should be set before inserting a page macro. The same settings can be used for installer and uninstaller pages.
!include MUI2.nsh
!define MUI_WELCOMEPAGE_TEXT "Blahblah install $(^NameDA).$\r$\n$\r$\nBlah blah blah"
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
!define MUI_WELCOMEPAGE_TEXT "Blahblah uninstall $(^NameDA).$\r$\n$\r$\nBlah blah blah"
!insertmacro MUI_UNPAGE_WELCOME
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_UNPAGE_FINISH
!insertmacro MUI_LANGUAGE "English"

When I customize the bitmap image in NSIS installer Welcome screen the updated bitmap image is not reflecting

As part of my project, when I customize the bitmap image in NSIS installer Welcome screen the updated bitmap image is not reflecting.
I used the below line to change the bitmap image:
!define MUI_DEFAULT_MUI_WELCOMEFINISHPAGE_BITMAP "E:\Source\NULLSOFT\src\Bitmaps\dlgbmp.bmp"
Below is the code snippet:
;Pages
;Customizing the bitmap image
!define MUI_DEFAULT_MUI_WELCOMEFINISHPAGE_BITMAP "E:\Source\NULLSOFT\src\Bitmaps\dlgbmp.bmp"
!insertmacro MUI_PAGE_WELCOME
;Languages
!insertmacro MUI_LANGUAGE "English" ; The first language is the default language
!insertmacro MUI_LANGUAGE "French"
Do we need to do any additional changes to update the new bitmap? Please help me.
There is no define named MUI_DEFAULT_MUI_WELCOMEFINISHPAGE_BITMAP, see the MUI documentation for valid defines.
In you case the define is named MUI_WELCOMEFINISHPAGE_BITMAP:
!include MUI2.nsh
!define MUI_WELCOMEFINISHPAGE_BITMAP "${NSISDIR}\Contrib\Graphics\Wizard\orange.bmp"
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_LANGUAGE "English"

NSIS Modern UI Finish Page

I would like to build an installer for my application using NSIS, but I faced a problem on the finish page. It looks like a big white rectangle around a checkbox. The rectangle cuts the 'Nullsoft Install System v3.03' subtitle. Here it is a screenshot:
Here it is a code:
!include "MUI2.nsh"
Name "My cool app"
OutFile "MyCoolAppInstaller.exe"
InstallDir "C:\MyCoolApp"
!define MUI_FINISHPAGE_RUN "$INSTDIR\app.exe"
!define MUI_FINISHPAGE_RUN_TEXT "Run App now"
!define MUI_FINISHPAGE_RUN_NOTCHECKED
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
Section
SetOutPath "$INSTDIR"
File app.exe
File smth.res
SectionEnd
Does anybody know how to fix it?
You need to add at least one language after the page macros:
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!define MUI_FINISHPAGE_RUN "$INSTDIR\app.exe"
!define MUI_FINISHPAGE_RUN_TEXT "Run App now"
!define MUI_FINISHPAGE_RUN_NOTCHECKED
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_LANGUAGE English
Adding a language will finalize some of the things in the UI and it does not look correct without it.

Making Chrome Extension Installer In NSIS

!define PRODUCT_VERSION "7.0.0"
!define CRXNAME "1.crx"
!define CRXID "xxxxxxxxxxxxxxxxxx"
!define INSTALL_DIR "$LOCALAPPDATA\Google\Chrome\User Data\Default\Extensions\${CRXID}\${PRODUCT_VERSION}_0"
!define P_FILE "$LOCALAPPDATA\Google\Chrome\User Data\Default\Preferences"
Function .onInit
SetSilent silent
FunctionEnd
Folder Is Getting Created But its Blank.
Empty Folder Without my .crx files.
my .crx is in same directory.
I want this installer to add extension to chrome.
The File instruction places files in the path set by SetOutPath, try:
Section
SetOutPath "${INSTALL_DIR}"
File "${CRXNAME}"
...
SectionEnd
You can also set the $instdir variable with InstallDir "${INSTALL_DIR}"

Resources