我想仅当 txt 文件中存在特定字符串时才继续运行批处理。
示例:
setlocal ENABLEDELAYEDEXPANSION
if....
Findstr "check_ok" "C:\tmp\test.txt"
(
...continue...
) ELSE (
exit
)
但我不想创建文件。
我找不到正确的方法......
最佳答案
很难准确说出您在问什么,因为您已经在运行批处理文件,所以如何不运行批处理文件来确定是否应该运行批处理文件?
无论如何,我会看看这是否对您有帮助:
@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
关于windows - BATCH 检查txt文件是否包含字符串并执行批处理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58593946/