如何在卸载程序中使用安装程序变量?
How to use installer variables in the uninstaller?
这是我的用例,这样您就可以理解为什么我需要卸载程序。
我必须修改在带有文件选择器的屏幕中选择的 WAR 文件的内容,首先用数据库备份它,然后修改数据库,然后 WAR.
WAR 和数据库的修改就像一个魅力,备份也是如此,但是我需要给最终用户一个可能性,就像恢复以前的 WAR 和数据库一样容易,他修改了它们。
为此,我创建了一些将使用备份文件和安装程序运行时变量的操作,但在执行卸载程序时出现错误,说它无法加载主程序 class.
我只是不使用任何启动器,因为实际上我并没有尝试安装任何软件,只是进行一些文件操作。
所以我的问题是:
- 是否可以使用卸载恢复备份文件?
- 是否可以在其他应用程序中使用安装程序变量?
编辑:
在卸载程序中,我需要使用安装程序中的表单组件变量,以及我在安装程序中使用 "Set a Variable" 操作创建的其他变量,为此我必须检查 Register to Response File复选框。
然后在卸载程序的启动节点中,在 "Request privileges" 操作之后,我添加了 "Load response file" 操作,并将 "File" 文本字段留空,以便它可以加载
安装程序创建的默认响应文件。
然后我在卸载程序的后续操作中调用这些变量
${installer:variableName}
,就像你说的,但我收到一个错误对话框,上面写着:
在生成的日志文件中使用此堆栈:
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.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.access0(Unknown Source)
at com.install4j.runtime.installer.helper.comm.HelperCommunication.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.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.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.access0(Unknown Source)
at com.install4j.runtime.installer.helper.comm.HelperCommunication.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.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.access0(Unknown Source)
at com.install4j.runtime.installer.helper.comm.HelperCommunication.run(Unknown Source)
Is it possible to restore the backup files using the uninstallation?
这已在上面的评论中解决。
Is it possible to use installer variables in other applications?
是的,在卸载程序的 "Startup" 节点中添加一个 "Load a response file" 操作。该变量必须是响应文件变量。绑定到表单组件的所有变量都会自动注册到响应文件中。对于其他变量,当您在安装程序配置的 "Installer variables" 选项卡上预定义安装程序变量时,会出现一个复选框。或者,您可以致电
context.registerResponseFileVariable(...);
在安装程序的 "Run script" 操作中。
在卸载程序中,您可以在文本字段中使用语法 ${installer:variableName}
或通过 context.getVariable("variableName")
.
在脚本中使用这些响应文件变量
这是我的用例,这样您就可以理解为什么我需要卸载程序。
我必须修改在带有文件选择器的屏幕中选择的 WAR 文件的内容,首先用数据库备份它,然后修改数据库,然后 WAR.
WAR 和数据库的修改就像一个魅力,备份也是如此,但是我需要给最终用户一个可能性,就像恢复以前的 WAR 和数据库一样容易,他修改了它们。
为此,我创建了一些将使用备份文件和安装程序运行时变量的操作,但在执行卸载程序时出现错误,说它无法加载主程序 class.
我只是不使用任何启动器,因为实际上我并没有尝试安装任何软件,只是进行一些文件操作。
所以我的问题是:
- 是否可以使用卸载恢复备份文件?
- 是否可以在其他应用程序中使用安装程序变量?
编辑:
在卸载程序中,我需要使用安装程序中的表单组件变量,以及我在安装程序中使用 "Set a Variable" 操作创建的其他变量,为此我必须检查 Register to Response File复选框。
然后在卸载程序的启动节点中,在 "Request privileges" 操作之后,我添加了 "Load response file" 操作,并将 "File" 文本字段留空,以便它可以加载
安装程序创建的默认响应文件。
然后我在卸载程序的后续操作中调用这些变量
${installer:variableName}
,就像你说的,但我收到一个错误对话框,上面写着:
在生成的日志文件中使用此堆栈:
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.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.access0(Unknown Source)
at com.install4j.runtime.installer.helper.comm.HelperCommunication.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.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.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.access0(Unknown Source)
at com.install4j.runtime.installer.helper.comm.HelperCommunication.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.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.access0(Unknown Source)
at com.install4j.runtime.installer.helper.comm.HelperCommunication.run(Unknown Source)
Is it possible to restore the backup files using the uninstallation?
这已在上面的评论中解决。
Is it possible to use installer variables in other applications?
是的,在卸载程序的 "Startup" 节点中添加一个 "Load a response file" 操作。该变量必须是响应文件变量。绑定到表单组件的所有变量都会自动注册到响应文件中。对于其他变量,当您在安装程序配置的 "Installer variables" 选项卡上预定义安装程序变量时,会出现一个复选框。或者,您可以致电
context.registerResponseFileVariable(...);
在安装程序的 "Run script" 操作中。
在卸载程序中,您可以在文本字段中使用语法 ${installer:variableName}
或通过 context.getVariable("variableName")
.