我正在使用install4j 6.1.6,我正在尝试执行以下操作:
我想外部运行一个来自安装程序的参数(第一个屏幕(的参数,然后在第二个屏幕上显示结果。
所以,第一个屏幕具有:
- 一些输入字段
- "运行可执行文件或批处理文件"操作
- 可执行文件:$ {installer:sys.javahome} bin java
- 以前输入字段的参数
- 检查"等待终止"
- "返回代码的可变名称"是 my-returnCode
- "重定向stderr"到安装程序变量 my-stderr
- 和一个"运行脚本"操作,该操作将自动进入下一个屏幕
- context.gotoscreen(context.getScreenByid(" nextScreenId"((;返回true;
第二个屏幕根据 my-returnCode 和 my-stderr 。
的值显示了适当的标签每种情况都可以正常工作。
但是,我决定更改第二个屏幕上的"后退按钮" 始终可见,因为用户可以解决问题(如果他在输入字段中输入错误(。
所以我在第一个屏幕上检查了"可以多次执行多次"操作。
现在,当我在输入字段中输入错误的数据时,单击Next >
脚本将运行并失败,第二个屏幕会说有一个错误。 my-returnCode 和 my-stderr 包含退出代码和错误消息。
然后我单击< Back
按钮并解决问题,我单击Next >
,然后脚本成功运行,但我仍然会收到以前的错误,因为 my-returnCode 和 my-stderr 未更新,它们仍然包含最后一个错误消息和退出代码!
在这种情况下,我该如何解决此问题并使安装4J更新变量?
更新:
我已经意识到第二个动作(转到下一个屏幕(是完全不必要的,所以我删除了它。
这仍然没有解决我的问题,以下是.install4j/installation.txt
的相关部分:
[INFO] com.install4j.runtime.beans.screens.FormScreen [ID 1199]: Show screen
Variable changed: shouldLaunchExternalScript=true[class java.lang.String]
Variable changed: externalScriptDataFolder=F:badfolderpath[class java.lang.String]
这是用户可以选择启动此外部脚本并设置数据文件夹的屏幕。我单击"启动脚本"广播按钮并设置一个不良文件夹路径。
[INFO] com.install4j.runtime.beans.actions.misc.RunExecutableAction [ID 1367]: Execute action
Property arguments: [-cp, ./*, -Ddata.dir=F:badfolderpath, ...]
Property rollbackSupported: false
Property returnCodeVariable: my-returncode
Property stdoutRedirectionMode: No redirection
Property stdoutVariableName:
Property workingDirectory: ...
Property failOnStderrFileError: false
Property failOnStdinFileError: false
Property failOnStdoutFileError: false
Property rollbackExecutable: null
Property rollbackArguments: null
Property rollbackWorkingDirectory: null
Property stderrRedirectionMode: To installer variable
Property stderrVariableName: my-stderr
Property stdinRedirectionMode: No redirection
Property environmentVariables: {}
Property keepConsoleWindow: true
Property showWindowsConsole: false
Property useRollbackExecutable: false
Property includeParentEnvironmentVariables: true
Property stdinString:
Property timeout: 0
Property stdinFile: null
Property stderrFile: null
Property stdoutFile: null
Property wait: true
Property waitForStreams: true
Property executable: c:usersuserappdatalocaltempe4jb23d.tmp_dir1564671223jrebinjava
Property logArguments: true
used working dir: ...
execute using batch file
脚本是用给定参数启动的,它将失败:
[ERROR] com.install4j.runtime.beans.actions.misc.RunExecutableAction [ID 1367]: return value is 1
[INFO] com.install4j.runtime.beans.actions.misc.RunExecutableAction [ID 1367]: Variable changed: my-stderr
Variable changed: my-returncode=1[class java.lang.Integer]
[ERROR] com.install4j.runtime.beans.actions.misc.RunExecutableAction [ID 1367]: return value is 1
Execute action not successful after 19696 ms
[INFO] com.install4j.runtime.beans.screens.FormScreen [ID 1199]: command: move 1 screens, executing actions, checking condition
[INFO] com.install4j.runtime.beans.screens.FormScreen [ID 1360]: Show screen
返回代码1表示失败,0表示在外部脚本中的成功。变量已更新,现在我在第二个屏幕上看到了外部脚本失败。我立即单击并解决问题(选择正确的文件夹路径(:
[INFO] com.install4j.runtime.beans.screens.FormScreen [ID 1360]: command: go back 1 screens using history
[INFO] com.install4j.runtime.beans.screens.FormScreen [ID 1199]: Show screen
Variable changed: shouldLaunchExternalScript=true[class java.lang.String]
Variable changed: externalScriptDataFolder=F:goodfolderpath[class java.lang.String]
变量已更新,外部脚本再次以正确的参数启动:
[INFO] com.install4j.runtime.beans.actions.misc.RunExecutableAction: Execute action
Property arguments: [-cp, ./*, -Ddata.dir=F:goodfolderpath, ...]
Property rollbackSupported: false
Property includeParentEnvironmentVariables: true
Property stderrFile: null
Property executable: c:usersuserappdatalocaltempe4jb23d.tmp_dir1564671223jrebinjava
Property stdinString:
Property wait: true
Property stdinFile: null
Property stdoutFile: null
Property waitForStreams: true
Property logArguments: true
Property timeout: 0
Property stderrVariableName: my-stderr
Property stdinRedirectionMode: No redirection
Property rollbackArguments: null
Property stdoutRedirectionMode: No redirection
Property rollbackWorkingDirectory: null
Property workingDirectory: ...
Property stdoutVariableName:
Property environmentVariables: {}
Property returnCodeVariable: my-returncode
Property rollbackExecutable: null
Property stderrRedirectionMode: To installer variable
Property useRollbackExecutable: false
Property failOnStdinFileError: false
Property failOnStdoutFileError: false
Property failOnStderrFileError: false
Property showWindowsConsole: false
Property keepConsoleWindow: true
used working dir: ...
execute using batch file
Variable changed: my-stderr
Variable changed: my-returncode=0[class java.lang.Integer]
Execute action successful after 16416 ms
脚本成功运行,变量更改(my-returnCode是1,现在是0(。
[INFO] com.install4j.runtime.beans.screens.FormScreen [ID 1199]: command: move 1 screens, executing actions, checking condition
[INFO] com.install4j.runtime.beans.screens.FormScreen [ID 1360]: Show screen
但是,在结果屏幕上,我仍然看到未更新的,以前的my-stderr和my-returnCode值,表明运行外部脚本存在错误。
我可以通过将此行添加到第二个屏幕的预启动脚本:
来解决问题:formEnvironment.reinitializeFormComponents();