I am trying to include in a batch file a check to see if a java process is already running before attempting to start it.
I have the following working command:
FOR /F "tokens=*" %g IN ('wmic PROCESS where "name like '%java%' and CommandLine like '%surveyEngine%'" get ProcessId') DO (SET var=%g)
ECHO %var%
However, the var
variable is NOT being set correctly.
When I run the initial wmic command I get three lines returned;
) Users\gavin>(SET var=ProcessId
) Users\gavin>(SET var=4964
) Users\gavin>(SET var=
and if I attempt to ECHO %var%
I get ECHO is on
and not a value.
Can anyone see any tweaks to my command that will allow me to capture the second line?
I am not "stuck on" using wmic... I just care about is this process running, or not.