Wait for process to finish before proceeding in Java

后端 未结 4 1302
無奈伤痛
無奈伤痛 2020-12-01 18:24

Essentially, I\'m making a small program that\'s going to install some software, and then run some basic commands afterwards to prep that program. However, what is happening

4条回答
  •  没有蜡笔的小新
    2020-12-01 19:19

    Include waitFor(). In your case, your code will look something like below.

        Main.say("Installing...");
        Process p1 = Runtime.getRuntime().exec(dir + "setup.exe /SILENT");
        p1.waitFor()
        Main.say("Registering...");
        Process p2 = Runtime.getRuntime().exec(installDir + "program.exe /register aaaa-bbbb-cccc");
        Main.say("Updating...");
        Process p4 = Runtime.getRuntime().exec(installDir + "program.exe /update -silent");
    

提交回复
热议问题