简体   繁体   English

将进度条链接到 Install4j 中的批处理文件执行

[英]Link Progress Bar To Batch File Execution in Install4j

Can I link a progess bar to install4j's execution of a batch file?我可以将进度条链接到 install4j 对批处理文件的执行吗?

I can execute my batch file or shell file via ProcessBuilder but I'm not sure how to signal progress bar in install4j我可以通过 ProcessBuilder 执行我的批处理文件或 shell 文件,但我不确定如何在 install4j 中发送进度条

Run Script Step运行脚本步骤

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);

If a progress bar is visible on a screen you can set the progress by calling如果屏幕上显示进度条,您可以通过调用设置进度

context.getProgressInterface().setPercentCompleted(...);

You need a percent value for that purpose.为此,您需要一个百分比值。 If you don't have such a value, you can set the progress bar to indeterminate by calling如果你没有这样的值,你可以通过调用将进度条设置为不确定

context.getProgressInterface().setIndeterminateProgress(true);

Setting the progress is also possible with the "Set the progress bar" action.也可以使用“设置进度条”操作来设置进度。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM