I've been trying to turn the output of the following two commands into variables, so that I can use them in a batch file, however I'm not having any luck:
WMIC /namespace:\\root\SecurityCenter2 PATH AntiVirusProduct WHERE (displayName="Emsisoft Anti-Malware" or displayName="Emsisoft Internet Security") GET displayName /value
WMIC /namespace:\\root\SecurityCenter2 PATH AntiVirusProduct WHERE (displayName="Emsisoft Anti-Malware" or displayName="Emsisoft Internet Security") GET pathToSignedReportingExe /value
Basically two different security products can potentially be installed, and the batch file needs to determine which one. Since the folder can potentially be changed during install, the safest way to determine that seems to be with the above two commands. Sadly, I can't get the output into variables in order to use it.
Here's my current test script:
@ECHO OFF
for /f "tokens=2 delims==" %%f in ('WMIC /namespace:\\\\root\\SecurityCenter2 PATH AntiVirusProduct WHERE ^(displayName^="Emsisoft Anti-Malware" or displayName^="Emsisoft Internet Security"^) GET DisplayName /value ^| find "="') do set "EmsiProductName=%%f"
ECHO %EmsiProductName%
for /f "tokens=2 delims==" %%f in ('WMIC /namespace:\\\\root\\SecurityCenter2 PATH AntiVirusProduct WHERE ^(displayName^="Emsisoft Anti-Malware" or displayName^="Emsisoft Internet Security"^) GET pathToSignedReportingExe /value ^| find "="') do set "EmsiProductPath=%%f"
ECHO %EmsiProductPath%
PAUSE
When run, the above outputs two errors that say "Description = The RPC server is unavailable." I've tried escaping the quotes (both ""
and \"
), and not escaping them, but the output is the same either way.
I'm out of ideas, so if anyone has any suggestions, then I would greatly appreciate it.