Archive: Add/Remove Programs icons and overwrite


Add/Remove Programs icons and overwrite
  I have a couple of questions regarding Add/Remove Programs that I've looked high and low for answers but have found nothing that solves my problems. I hope someone here can help.

I want to add an icon in A/R P but the code I am using does not seem to work. Here's the line of code in Section -Post.
For clarity:
PURK = PRODUCT_UNINST_ROOT_KEY, PUK = PRODUCT_UNINST_KEY)

WriteRegStr ${PURK} "${PUK}" "DisplayIcon" "${NSISDIR}\Contrib\Graphics\Icons\uninstall.ico"

Also, my installer adds an entry into A/R P just fine, except for the above tweak. Or so I thought. When I built and ran an installer that had a different version of the same product I expected to find a second entry in A/R P. Instead, I find that the new entry overwrites the original. Here is the code:

WriteRegStr ${PURK} "${PUK}" "DisplayName" "$(^Name)"
WriteRegStr ${PURK} "${PUK}" "UninstallString" "$INSTDIR\uninst.exe"
WriteRegStr ${PURK} "${PUK}" "DisplayVersion" "${PRODUCT_VERSION}"
WriteRegStr ${PURK} "${PUK}" "Publisher" "${PRODUCT_PUBLISHER}"

One last question, where does $(^Name) come from? I've tried to view it using MessageBox but was unable. What is the carat doing?


Thanks.
p.s., in the name of full disclosure I'm forced to use NSIS version 2.39 so, if there are fixes in later versions to these problems, please let me know so I can build a case.


"$(^Name)"
comes from the Installer "Name" directive.

"${NSISDIR}\Contrib\Graphics\Icons\uninstall.ico"
wouldn't work on any machine other than those who have that icon file in the exact same location on their machine; which is probably not your end-users.
Best is to use an icon in the uninstaller itself, btw - ARP will use that icon from the executable automatically.


Thanks for the .ico observation - doh! I should have known that.

Are you saying that ${^Name} is the same as ${PRODUCT_NAME}? If so, why the alias and what's with the ^?

My most pressing question though is why I can't get multiple versions of uninstallers in Add/Remove Programs.


no, ${PRODUCT_NAME} is probably a define somewhere in the script you're working with; sounds like an HMSoft NIS Edit default define name.

$(^Name) (not ${^Name} - curly braces here) is a so-called 'langstring' variable. It changes the string based on whatever language your installer uses (in some installers, that can be decided by the user, typically on startup).

--

as for your ARP.. if you want multiple entries, you'll need separate registry key files. Try adding the version number or so to the registry key.


I got the ARP entries to be unique per build - thank you.

But I still can't get the icon in ARP to work. I put a copy of the .ico file in the same directory as my .nsi file but that didn't help. Here's what I do have that works as desired:

; The icon in the top right corner of the installer windows and the desktop icon.
!define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\my_1.ico"

; The icon for the installer in the directory, not in Add or Remove Programs.
!define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\my_1_un.ico"

...

And this does not work as desired:

Section -Post
...

; Shows up as a registry Name/Data entry. ARP icon not changed.
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayIcon" "my_uninstall.ico,4"

; Also tried, with similar results (no icon index):
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayIcon" "my_uninstall.ico"

...

I suspect I'm missing something obvious but I just don't see it. Thanks again for your help.


I think you have to specify the -full path- to the resource file (in your case, "my_uninstall.ico") - so including any "c:\program files\myApp\my_uninstall.ico" bits.


a .ico does not have a icon index, its just one icon, so just using the full path without a index should work


I hate to sound dense but I'm still not there yet. I modified the line in my .nsi script in Section -Post:
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayIcon" "${NSISDIR}\Contrib\Graphics\Icons\my_uninstall.ico"

by replacing ${NSISDIR} with its explicit c:\... path.

I still don't see the icon I want in ARP. In fact, it is using an icon from the folder of one of the tools. Should I expect to see the .ico in the delivered product? Should I be using the path to this icon? That doesn't seem right. I thought it would be incorporated into the installer's .exe like it does the other icons.

The .ico file I am using is composed of four separate images of different sizes. I thought that was standard for .ico files that are used as resources.

Is there some sample code someone can point me to?


${NSISDIR} is a path on your system, not the users system.

try:


Section

SetOutPath $instdir
File "${NSISDIR}\\Contrib\\Graphics\\Icons\\my_uninstall.ico"
>WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayIcon" "$instdir\\my_uninstall.ico"
>SectionEnd
>

Okay, thanks. But that puts a copy of the .ico file into my deliverable. Is this how it's supposed to work, the .ico file has to be installed? None of the other icon files, like those that adorn the install window, are installed. Why would this be different?


yes, it has to be installed because the end-user's machine needs to be able to find that icon file.

The icons for the installer itself (top-left corner, usually, and explorer views of the installer, etc. etc.) are inside the .exe itself. So if you place that .exe on the machine's computer, that icon is, in a way, placed on the end-user's machine as well.

If you don't want to install the icon file, you may be able to add the uninstall icon to the uninstaller executable, and then reference it using e.g. "$instdir\uninstaller.exe,N", where N would the icon index within the uninstaller.
But I suspect that might be more trouble than it's worth.


Thanks. It's making sense.