Batch file 从列表中排除项目

Batch file 从列表中排除项目,batch-file,Batch File,因此,我有一个exe文件列表,我将其存储到一个数组中。现在,我想执行它找到的第一个exe,只要它不是我不希望运行的特定文件(PATCH_TB.exe)。这是我的密码: REM Count total EXE's and store into array set /a "i=0" for %%f in (*.exe) do ( if NOT %%f=="PATCH_TB.exe" ( set /a "i+=1"

因此,我有一个exe文件列表,我将其存储到一个数组中。现在,我想执行它找到的第一个exe,只要它不是我不希望运行的特定文件(PATCH_TB.exe)。这是我的密码:

REM Count total EXE's and store into array
set /a "i=0"
for %%f in (*.exe) do (
    if NOT %%f=="PATCH_TB.exe" (
        set /a "i+=1"
        set "list[!i!]=%%f"
    ) else echo > nul
)

REM Get EXE at index of i and run it
SET active_game=!list[1]!
START "" %active_game%

我的代码正确吗?有没有更好的解决办法?谢谢大家!

您应该进行一些测试,以确定代码是否正确。只要它按预期工作,它就是正确的。