I am not sure of this is teh right forum to ask this question. If not, kindly direct me to the correct forum.
I am trying to call a WMI command from a batch file like below:
for /f "tokens=2 delims==" %%f in ('wmic /namespace:\some command /value ^| find "="') do set "val=%%f"
IF "%val%"==""( echo Null. Exiting...
Exit /B
)
The issue is if the WMI command didn't find the query result, then I expect the query to return an empty string. The value I am looking for is a string. So the above empty string comparison does not work so I am not getting the "Exiting...." statement. What is wrong here? What more is to done in the comparison? .The value I am looking for doesn't exist and the script says "No instances found" in command prompt. But I need to inform the user in a nice way. How do one does string or empty comparisons in batch files?