Batch - How to wait for process with specific name so start and finish?

Daniel Kvist

I'm creating a launch script to start a game launcher which requires a specific Java version. It currently looks like this:

@ECHO OFF
echo Enabling Java 7...
SET JAVA_HOME=C:\Program Files\Java\jre7
echo Active Java version location: %JAVA_HOME%
echo Starting ATLauncher...
start /wait ATLauncher.exe
echo Launcher started!

It just sets the Java version to Java 7 (changes the JAVA_HOME environment variable to the path to the Java 7 jre) and starts the game launcher (ATLauncher.exe) and waits for it to finish. This does what I want it to, except one thing: The process ATLauncher.exe is just a "starter" which starts a debug console and a Java application, which prompts the user to select something to play, and then starts the selected application.

This brings two problems:
1: All applications started after the ATLauncher.exe process are Java programs, so their process names are just javaw.exe, so it's hard to identify them.
2: The batch file closes when the ATLauncher.exe process stops (which is what I expect), but I want it to run until the last of the launched Java processes has been terminated, and then run some more commands, and then stop.

Here is the "flow" I want to achieve:

  1. The script is started.
  2. The JAVA_HOME variable is changed.
  3. The process ATLauncher.exe starts.
  4. The process ATLauncher.exe starts two javaw.exe processes.
  5. The process ATLauncher.exe stops.
  6. One of the javaw.exe processes starts a 3rd javaw.exe process.
  7. The 3rd javaw.exe process stops.
  8. The 1st and 2nd javaw.exe eventually stops, or the "flow" begins from step 6 again.
  9. The script executes some more commands and stops.

I hope this is clear enough! Just tell me if I have to explain something a bit clearer!

Thanks!

Endoro

Try this:

:loop
rem wait 4 sec
ping -n 5 localhost >nul
tasklist /fi "IMAGENAME EQ javaw.exe" /fi "STATUS EQ RUNNING" | find /i "javaw.exe" > nul && goto:loop
rem more commands here

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Batch - How to wait for process with specific name so start and finish?

From Dev

wait for the process to finish to start another process

From Dev

wait for the process to finish to start another process

From Dev

How to wait for a background process to finish in android

From Dev

How to wait for the copying process (cp) to finish?

From Dev

How to wait all batch files to finish before exiting?

From Dev

How to wait for a child process to finish in Node.js?

From Dev

For loop and mysql node how to wait for all queries to finish to process view

From Dev

Wait for process to finish, or user input

From Dev

wait a process to finish in Python script

From Dev

How to start detached process and wait for the parent to terminate?

From Dev

How to wait for subscribe to finish?

From Dev

How to wait for a task to finish

From Dev

How can I start a process and give it a different name in Task Manager via a batch script?

From Dev

wait one process to finish and execute another process

From Dev

Start process and wait until logfile has specific entry

From Dev

How to finish batch and redirect then

From Dev

How to finish batch and redirect then

From Dev

Run methods in new process and wait for them to finish

From Dev

Ruby: wait for any child process to finish

From Dev

Wait for async process to finish before redirect in koajs

From Dev

Ruby: wait for any child process to finish

From Dev

Wait for a process to finish OR for the user to press a key

From Dev

Bash to Call PHP, Wait for PHP Process to finish?

From Dev

Run methods in new process and wait for them to finish

From Dev

Timer to wait for loop finish working and start again

From Dev

Wait for any task to finish, then start a new one

From Dev

How do you wait on a Task Scheduler task to finish in a batch file or C#?

From Dev

How to wait for JavaScript to finish in playwright

Related Related

  1. 1

    Batch - How to wait for process with specific name so start and finish?

  2. 2

    wait for the process to finish to start another process

  3. 3

    wait for the process to finish to start another process

  4. 4

    How to wait for a background process to finish in android

  5. 5

    How to wait for the copying process (cp) to finish?

  6. 6

    How to wait all batch files to finish before exiting?

  7. 7

    How to wait for a child process to finish in Node.js?

  8. 8

    For loop and mysql node how to wait for all queries to finish to process view

  9. 9

    Wait for process to finish, or user input

  10. 10

    wait a process to finish in Python script

  11. 11

    How to start detached process and wait for the parent to terminate?

  12. 12

    How to wait for subscribe to finish?

  13. 13

    How to wait for a task to finish

  14. 14

    How can I start a process and give it a different name in Task Manager via a batch script?

  15. 15

    wait one process to finish and execute another process

  16. 16

    Start process and wait until logfile has specific entry

  17. 17

    How to finish batch and redirect then

  18. 18

    How to finish batch and redirect then

  19. 19

    Run methods in new process and wait for them to finish

  20. 20

    Ruby: wait for any child process to finish

  21. 21

    Wait for async process to finish before redirect in koajs

  22. 22

    Ruby: wait for any child process to finish

  23. 23

    Wait for a process to finish OR for the user to press a key

  24. 24

    Bash to Call PHP, Wait for PHP Process to finish?

  25. 25

    Run methods in new process and wait for them to finish

  26. 26

    Timer to wait for loop finish working and start again

  27. 27

    Wait for any task to finish, then start a new one

  28. 28

    How do you wait on a Task Scheduler task to finish in a batch file or C#?

  29. 29

    How to wait for JavaScript to finish in playwright

HotTag

Archive