Link Install4j 中批处理文件执行的进度条

Link Progress Bar To Batch File Execution in Install4j

我可以 link 一个进度条来执行 install4j 的批处理文件吗?

我可以通过 ProcessBuilder 执行我的批处理文件或 shell 文件,但我不确定如何在 install4j 中指示进度条

运行 脚本步骤

File installationDir = new File((String)context.getVariable("sys.installationDir"));
File executable = new File(installationDir, "bin/start.sh");
File logFile = new File(installationDir, "autorun.out.log");

ProcessBuilder pb = new ProcessBuilder(executable.getAbsolutePath(), 
"-p", (String)context.getVariable("projectsdir"),
"-n", (String)context.getVariable("projectname"));

 pb.redirectErrorStream(true);
 pb.redirectOutput(logFile);
 pb.directory(installationDir);
 Process p = pb.start();
 p.waitFor();
return (p.exitValue() == 0);

如果屏幕上显示进度条,您可以通过调用

设置进度
context.getProgressInterface().setPercentCompleted(...);

为此,您需要一个百分比值。如果你没有这样的值,你可以通过调用

设置进度条不确定
context.getProgressInterface().setIndeterminateProgress(true);

设置进度也可以使用 "Set the progress bar" 操作。