大家好
尋問一下批次檔的語法
我想要在Client端(Win7)上偵測是否已安裝指定的更新包,
所以下了如下的批次
IF not exist (wmic qfe list full ^| find "KB4012215") (
echo KB4019264未安裝,仍有勒索漏洞 >> log.txt
)
IF not exist (wmic qfe list full ^| find "KB4015549") (
echo KB4019264未安裝,仍有勒索漏洞 >> log.txt
)
IF not exist (wmic qfe list full ^| find "KB4019264") (
echo KB4019264未安裝,仍有勒索漏洞 >> log.txt
)
但一直會出現錯誤訊息: 'qfe' 不是內部或外部命令、可執行的程式或批次檔。
想問一下語法怎麼調整比較好?
感謝koro_michael協助,目前版本
set result="Nothing"
FOR /F "" %%r in ('wmic qfe list full ^| find "KB4012215"') do set result=%%r
if "Nothing"==%result% echo KB4012215 not install >> log.txt
set result="Nothing"
FOR /F "" %%r in ('wmic qfe list full ^| find "KB4015549"') do set result=%%r
if "Nothing"==%result% echo KB4015549 not install >> log.txt
set result="Nothing"
FOR /F "" %%r in ('wmic qfe list full ^| find "KB4019264"') do set result=%%r
if "Nothing"==%result% echo KB4019264 not install >> log.txt
儲存其他程式的輸出到變數
FOR /F "" %%r in ('wmic qfe list full ^| find "KB4012215"') do set result=%%r
程式迴圈概念
@echo off
set list[0]=KB4012215
set list[1]=KB4015549
set list[2]=KB4019264
set i=0
:loop
if not defined list[%i%] goto :end
call set s=%%list[%i%]%%
for /F %%r in ('wmic qfe list full ^| find "%s%"') do (
goto flag
)
echo "%s% not install" >> log.txt
:flag
set /a "i+=1"
goto loop
:end