Archive: Using Variables in the uninstall section


Using Variables in the uninstall section
I am using install options to have a user enter a information that I am tagging onto the end of a filename and creating a custom directory. The install works just fine, but it appears that the uninstaller is not being created with the variable information. When I view the detail in during an uninstall, where the variables are located in the script, there is a blank space in the uninstall detail.

Examples below:
Install line:
CopyFiles /Silent /Filesonly "$EXEDIR\eSecureTail.exe" "$WINDIR\$R2.exe" 58

Uninstall line:
Delete "$WINDIR\$R2.exe"

and

UninstallText "This will uninstall $R2 from your system"

In the uninstall text, it displays "$R2" in the text, it doesn't convert it to the value of the variable.

Any help would be greatly appreciated.
-Paul


How would the uninstaller know the value of $R2?

You have to save that variable somewhere (for example, in the registry) and read it in the uninstaller.

UninstallText is an installer atribute, so you cannot use a variable in it:

The commands below all adjust attributes of the installer. These attributes control how the installer looks and functions, including which pages are present in the installer, as what text is displayed in each part of each page, how the installer is named, what icon the installer uses, the default installation directory, what file it writes out, and more. Note that these attributes can be set anywhere in the file except in a Section or Function. With the exception of InstallDir, none of these attributes allow use of Variables other than $\r and $\n in their strings.

I understand the installdir text part, but what is confusing me is that the uninstaller knows $INSTDIR and $WINDIR. I would assume that these values are expanded into the uninstaller command lines when the uninstaller is created.

The uninstaller also gets this line correct....
DeleteRegKey HKEY_LOCAL_MACHINE "SOFTWARE\e-Security\eSecureTail\$R2"

and

Delete "$INSTDIR\$R2\uninst.exe"

But not this.....

ExecWait "net stop $R2"

It seems like in some cases the variable is converted to the value when it creates the uninstaller and sometimes not.....

Is there a way to get user input when uninstalling? Maybe use install options in the uninstall section?


$INSTDIR and $WINDIR are automatically set by the uninstaller ($INSTDIR is the directory where the uninstaller is located, $WINDIR can be retrieved using an API function).

$R2 is a normal general purpose variable. It's just in the memory when the installer runs, but it will not be saved to the disk. The uninstaller is a separate application which does not know anything about the installer variables.

$R2 in the uninstaller is empty by default. If you want to use the user input in the uninstaller, you should save this value to the disk.

Installer > Write $R2 to registry
Uninstaller > Get $R2 from registry