Here is my use case, so that you can understand why I need an uninstaller.
I have to modify the content of a WAR file chosen in a screen with a file chooser, back it up with the database first, then modify the database, and then the WAR.
The modification of the WAR and the database works like a charm, so does the backup, but then I need to give to the end user the possibility, to restore the previous WAR and database as easily as, he modified them.
For that I created some actions which will use the backup files, and the installer runtime variables, but I have an error showing at the execution of the uninstaller, saying that it couldn't load the main class.
I just don't use any launcher, because in fact I am not trying to install any software, just doing some files manipulations.
So my questions are:
- Is it possible to restore the backup files using the uninstallation?
- Is it possible to use installer variables in other applications?
Edit:
In the uninstaller, I need to use form components variables from the installer, and other variables that I created using the "Set a Variable" action in the installer too, for which I have to check the Register to Response File checkbox.
Then in the startup node of the uninstaller, after the "Request privileges" action, I add the "Load response file" action, and leave the "File" textfield empty, so it could load
the default response file created by the installer.
I then call those variables in the uninstaller's subsequent actions with
${installer:variableName}
, like you said, but I get an error dialog saying this:
with this stack in the log file that gets generated:
Exception:
com.install4j.api.beans.UndefinedVariableException: installer:zPath
at com.install4j.runtime.installer.InstallerVariables$InstallerReplacementCallback.handleError(Unknown Source)
at com.install4j.runtime.installer.InstallerVariables$InstallerReplacementCallback.getReplacement(Unknown Source)
at com.install4j.runtime.util.StringUtil.replaceVariable(Unknown Source)
at com.install4j.runtime.installer.InstallerVariables.replaceVariables(Unknown Source)
at com.install4j.runtime.installer.InstallerVariables.replaceVariables(Unknown Source)
at com.install4j.api.beans.AbstractBean.replaceVariables(Unknown Source)
at com.install4j.runtime.beans.actions.files.AbstractFileAction.getFiles(Unknown Source)
at com.install4j.runtime.beans.actions.files.AbstractFileAction.execute(Unknown Source)
at com.install4j.runtime.beans.actions.SystemInstallOrUninstallAction.uninstall(Unknown Source)
at com.install4j.runtime.installer.UninstallerContextImpl$2.fetchValue(Unknown Source)
at com.install4j.runtime.installer.helper.comm.actions.FetchObjectAction.execute(Unknown Source)
at com.install4j.runtime.installer.helper.comm.HelperCommunication.executeActionWrapper(Unknown Source)
at com.install4j.runtime.installer.helper.comm.HelperCommunication.access$200(Unknown Source)
at com.install4j.runtime.installer.helper.comm.HelperCommunication$1.run(Unknown Source)
I get two other error dialogs for another variable, here is its stack:
Exception:
com.install4j.api.beans.UndefinedVariableException: installer:zLoc
at com.install4j.runtime.installer.InstallerVariables$InstallerReplacementCallback.handleError(Unknown Source)
at com.install4j.runtime.installer.InstallerVariables$InstallerReplacementCallback.getReplacement(Unknown Source)
at com.install4j.runtime.util.StringUtil.replaceVariable(Unknown Source)
at com.install4j.runtime.installer.InstallerVariables.replaceVariables(Unknown Source)
at com.install4j.runtime.installer.InstallerVariables.replaceVariables(Unknown Source)
at com.install4j.runtime.installer.InstallerVariables.replaceVariables(Unknown Source)
at com.install4j.runtime.installer.InstallerVariables.replaceVariables(Unknown Source)
at com.install4j.api.beans.AbstractBean.replaceVariables(Unknown Source)
at com.install4j.runtime.beans.actions.misc.RunExecutableAction.getExecutable(Unknown Source)
at com.install4j.runtime.beans.actions.misc.RunExecutableAction.execute(Unknown Source)
at com.install4j.runtime.beans.actions.SystemInstallOrUninstallAction.uninstall(Unknown Source)
at com.install4j.runtime.installer.UninstallerContextImpl$2.fetchValue(Unknown Source)
at com.install4j.runtime.installer.helper.comm.actions.FetchObjectAction.execute(Unknown Source)
at com.install4j.runtime.installer.helper.comm.HelperCommunication.executeActionWrapper(Unknown Source)
at com.install4j.runtime.installer.helper.comm.HelperCommunication.access$200(Unknown Source)
at com.install4j.runtime.installer.helper.comm.HelperCommunication$1.run(Unknown Source)
Exception:
com.install4j.api.beans.UndefinedVariableException: installer:zLoc
at com.install4j.runtime.installer.InstallerVariables$InstallerReplacementCallback.handleError(Unknown Source)
at com.install4j.runtime.installer.InstallerVariables$InstallerReplacementCallback.getReplacement(Unknown Source)
at com.install4j.runtime.util.StringUtil.replaceVariable(Unknown Source)
at com.install4j.runtime.installer.InstallerVariables.replaceVariables(Unknown Source)
at com.install4j.runtime.installer.InstallerVariables.replaceVariables(Unknown Source)
at com.install4j.api.beans.AbstractBean.replaceVariables(Unknown Source)
at com.install4j.runtime.beans.actions.files.AbstractFileAction.getFiles(Unknown Source)
at com.install4j.runtime.beans.actions.files.AbstractFileAction.execute(Unknown Source)
at com.install4j.runtime.beans.actions.SystemInstallOrUninstallAction.uninstall(Unknown Source)
at com.install4j.runtime.installer.UninstallerContextImpl$2.fetchValue(Unknown Source)
at com.install4j.runtime.installer.helper.comm.actions.FetchObjectAction.execute(Unknown Source)
at com.install4j.runtime.installer.helper.comm.HelperCommunication.executeActionWrapper(Unknown Source)
at com.install4j.runtime.installer.helper.comm.HelperCommunication.access$200(Unknown Source)
at com.install4j.runtime.installer.helper.comm.HelperCommunication$1.run(Unknown Source)
This has been resolved in the comments above.
Yes, add a "Load a response file" action to the "Startup" node of the uninstaller. The variable must be a response file variable. All variables that are bound to form components are automatically registered for the response file. For other variables, there is a check box when you pre-define an installer variable on the "Installer variables" tab of the installer configuration. Alternatively, you can call
in a "Run script" action in the installer.
In the uninstaller, you can then use those response file variables in text fields with the syntax
${installer:variableName}
or in scripts viacontext.getVariable("variableName")
.