我想仅在txt文件中存在特定字符串的情况下才继续运行批处理。
示例:
setlocal ENABLEDELAYEDEXPANSION
if....
Findstr "check_ok" "C:\tmp\test.txt"
(
...continue...
) ELSE (
exit
)
但是我不想创建文件。
我找不到正确的方法...
答案 0 :(得分:3)
由于您已经在运行批处理文件,所以很难准确地问您要问的是什么,为什么不运行批处理文件来确定是否应运行批处理文件?
无论如何,我将看看这是否对您有帮助:
@echo off
setlocal enabledelayedexpansion
:: Check for "check_ok" and exit the batch file if it is NOT found
Findstr -m /S /C:"check_ok" "C:\tmp\test.txt" || goto :eof
:: If we get here, then check_ok was found
:: Continue with the rest of your batch file