Archive: Multiple installs on 1 machine with variables


Multiple installs on 1 machine with variables
All,

In a nutshell, I am using install options to ask for a port number and assigning it to $R2.
I am then appending this portnumber to the end of a service name and directory. Lets say 5000 for this example.

This creates a directory called $INSTDIR\$R2\ and the executable is appended with the $R2 variable, so when it runs it is running as app.exe5000 or whatever the port number is they entered.

The reason I am doing this is because the app can be installed many times to monitor many ports.

The uninstaller makes an uninstall app called uninst$R2 and the uninstall entry says "Uninstall app.exe5000". So far so good.

The problem I am having is as follows:
How do I make the uninstaller remove the appropriate directory?
If I tell it to delete $INSTDIR, it wipes out everything. If I tell it to delete $INSTDIR\$R2\, when the installer is written, it literally writes it as $\INSTDIR\$R2 instead of $INSTDIR\5000.
I have tried to write the values in the registry and an .ini file, but I cannot get the initial uninstall to look in the right directory or registry key without NSIS expanding the variable values when creating the uninstaller.

Any ideas? Hoping I can call writeUninstaller with a switch that passes variable values to it so it can populate them when creating the uninstaller. It somehow does pass $INSTDIR (and populates it at the time of creation) but doesn't seem to pass any other variables.

If there is no secret switch or something, is there a way I can get the name of the uninst.exe? Since I appended the port number to the end, I could read the filename of uninst$R2.exe and do an offset to repopulate $R2 uninstaller. The problem with offsets is how long is the port number? If I offset from the left side, is there a way to just read the filename? There is a command to get the full path and short path, creation date, etc, but how do I just get the name of a file without the path? If I offsetfrom the right using -4 and the port is 5 numbers long, it is going to be wrong.

Another though, is there a way to use a character as the offset value? For instance, instead of "strcpy 4" which copy 4 characters can I do something like "strcpy until ."? This would let me copy until it finds a "."

Last thought, is there a way to count the characters in a filename? If I can count the characters in a variable, I would know how many characters to offset. Or if I could could the characters in a filename, I could figure out how many to offset.

Sorry for making this so long, I am just hitting a brick wall from every angle I try and am looking for some fresh ideas.


To set $INSTDIR with vairables use the callback function .onInit and set $INSTDIR to whatever you want.

To get the uninstaller name process $CMDLINE.

To get the number of characters in a string use StrLen.

To pass variables to the uninstaller you will have to use the registry or an INI file. To change $INSTDIR according to them use .onInit that I have mentioned above.