使用数组查找命令的批处理循环
Batch Loop using array for find command
当前正在尝试在搜索文件中的特定字符串时遍历字符串数组。没有得到我想要的输出。
@echo off
wmic qfe get HotfixID > WinUpdateList.txt && set file=WinUpdateList.txt
set patch[0]=KB4012212
set patch[1]=KB4014985
set patch[2]=KB4014573
set patch[3]=KB4015546
set patch[4]=KB4018271
set patch[5]=KB4019263
set patch[6]=KB4019264
for /L %%a in (0,1,6) do (
>nul find /C "%patch[%%a]%" %file% && (
echo %patch[%%a]% was found.
) || (
echo %patch[%%a]% was NOT found.
)
)
能够通过以下更改获得我需要的结果。
for /L %%a in (0,1,6) do (
>nul find /C "!patch[%%a]!" %file% && (
echo !patch[%%a]! was found.
) || (
echo !patch[%%a]! was NOT found.
)
)
当前正在尝试在搜索文件中的特定字符串时遍历字符串数组。没有得到我想要的输出。
@echo off
wmic qfe get HotfixID > WinUpdateList.txt && set file=WinUpdateList.txt
set patch[0]=KB4012212
set patch[1]=KB4014985
set patch[2]=KB4014573
set patch[3]=KB4015546
set patch[4]=KB4018271
set patch[5]=KB4019263
set patch[6]=KB4019264
for /L %%a in (0,1,6) do (
>nul find /C "%patch[%%a]%" %file% && (
echo %patch[%%a]% was found.
) || (
echo %patch[%%a]% was NOT found.
)
)
能够通过以下更改获得我需要的结果。
for /L %%a in (0,1,6) do (
>nul find /C "!patch[%%a]!" %file% && (
echo !patch[%%a]! was found.
) || (
echo !patch[%%a]! was NOT found.
)
)