Old 15th June 2017, 01:25   #1
Junior Member
Join Date: Jun 2017
Posts: 2
Reading uninstaller name

From what I've found here on the forum, this is a bit of a long shot, but I am looking for a way to read the actual name of the uninstaller exe.

I have a number of installers which add flight simulator scenery, and they can install to more than one simulator. To differentiate between different installations, I append the simulator version to the uninstaller filename. Currently to determine which simulator scenery needs to be uninstalled, I just compare the $INSTDIR with each of the installed locations from the registry. This has worked well, but now I want to be able to reuse a particular install for another simulator -- so if a customer has two different simulators, they will share the same scenery install. So just reading $INSTDIR won't show which simulator needs to be uninstalled, as they will be in the same location.

I'd like to read the name of the uninstaller, and check the suffix. Is there any way to do this?
RobinCorn is offline   Reply With Quote
Old 15th June 2017, 02:07   #2
Major Dude
JasonFriday13's Avatar
Join Date: May 2005
Location: New Zealand
Posts: 870
See http://nsis.sourceforge.net/Docs/Chapter4.html#varother. String parsing can be done with StrCpy, StrLen, StrCmp, and maybe a string searching function as well, probably ${GetExeName} (use !include "filefunc.nsh").

"Only a MouseHelmet will save you from a MouseTrap" -Jason Ross (Me)
Wiki Profile
JasonFriday13 is offline   Reply With Quote
Old 15th June 2017, 04:06   #3
Anders's Avatar
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,946
This is a bit tricky because the uninstaller has a random name in %temp%.

I can think of two ways of dealing with this:

A) If it always has a common prefix you can search $InstDir with FindFirstFile looking for Uninst*.exe (Not sure if this works in your specific case, you might have to save the uninstaller in a subdirectory under $InstDir)

B) Use something like the WriteCustomerData function from the wiki to append something to the uninstaller after WriteUninstaller. You can then read this data in the uninstaller (reading from itself).

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 15th June 2017, 07:37   #4
Junior Member
Join Date: Jun 2017
Posts: 2
Cheers, guys.

Yes, I might end up creating a subfolder for a particular simulator, just for the uninstallers -- so I don't end up with two uninstallers for the same product in the one location, then I can continue to use $INSTDIR to pinpoint the version.

There is an alternative, which is just have a single uninstaller, and let the user choose which to uninstall. This might be preferable, to overcome some legacy installer issues.

Why is nothing simple?
RobinCorn is offline   Reply With Quote
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump