The excerpt you've posted works without error messages.Though if you want to include the space at the end in the variable name you can use the quotes like this:
@echo off
SETLOCAL EnableDelayedExpansion
set "var=value "
echo !var!
IF "!var!" == "value " (
echo Perfect )
edit based on the commends:
@echo off
setlocal enableDelayedExpansion
for /f "usebackq" %%f in (`"wmic process where name='java.exe' get commandline /format:value"`) do (
call ::run "%%~f"
)
:run
for /f "tokens=7" %%# in ("%%~1") do set "var=%%#"
echo "!var!"
IF "!var!"=="someValue " (
echo Already running
) Else (
echo S
topped
)