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:
JAVA_HOME
variable is changed.ATLauncher.exe
starts.ATLauncher.exe
starts two javaw.exe
processes.ATLauncher.exe
stops.javaw.exe
processes starts a 3rd javaw.exe
process.javaw.exe
process stops.javaw.exe
eventually stops, or the "flow" begins from step 6 again.I hope this is clear enough! Just tell me if I have to explain something a bit clearer!
Thanks!
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.
Comments