我可以将进度条链接到 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);
还可以通过“设置进度条”操作来设置进度。
关于java - 将进度条链接到 Install4j 中的批处理文件执行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37012502/