user1663380
user1663380

Reputation: 1013

Is it possible to prevent running of 2 instance of a java application in a batch file?

As task scheduler doesn't seem to be stopping me from running 2 instances, I have already enabled do not start a new instances

Upvotes: 0

Views: 215

Answers (1)

Bali C
Bali C

Reputation: 31231

Presuming you are actually asking for a batch solution rather than a Java one, and provided that you are starting the Java programs from the batch then you could do something like this

tasklist /nh /fi "imagename eq java.exe" | find /i "java.exe" >nul && (
echo Java already running, not going to run again
) || (
echo Java not running, so run it
java.exe whatever
)

Obviously you will have to replace java.exe whatever with your actual command.

If this isn't what you are looking for please add more specific info/requirements.

Upvotes: 1

Related Questions