我试图找到是否在Windows中安装了某些软件。我在下面找到命令来查找是否已安装产品
wmic product where name="Symantec Endpoint Protection"
其输出为No Instance(s) Available.
我已尝试但未成功将命令输出存储在批处理文件中的变量
中答案 0 :(得分:2)
您也可以这样做:
@echo off
echo Wait a while .....
wmic product where name="Symantec Endpoint Protection" > %tmp%\tmp.txt
Cmd /U /C Type %tmp%\tmp.txt > %tmp%\Symantec.txt
Start "" %tmp%\Symantec.txt
答案 1 :(得分:1)
要删除其他unicode符号,请将结果再放入一个FOR循环:
@echo off
for /f "usebackq tokens=* delims=" %%a in (`wmic product where name^='Symantec Endpoint Protection' 2^>^&1`) do (
for /f "tokens=* delims=" %%# in ("%%a") do set "result=%%~#"
)
if "%result%" equ "No Instance(s) Available." (
echo install something
)