Background: I use DOS START command to start MyDaemon:
@echo off
START "MyDaemon" java -cp test.jar MyTest /B
As part of this, I also want to check if MyDaemon is already running. If it is, I don’t want to start it again.
The dos command that doesn’t suit my requirement is:
tasklist /fi "imagename eq "MyDaemon" > nul
if errorlevel 1 start "MyDaemon" java -cp test.jar MyTest /B
and that’s because, in the tasklist, the image name is “java.exe”, not “MyDaemon”. I am looking for the “application name” as seen in task manager, not the image name.
So how can I perform this check to see if MyDaemon is already running using DOS?
You may try:
Type tasklist /? for further details.