批处理文件FIND命令给出错误

时间:2016-06-06 09:06:05

标签: batch-file find

以下是我在批处理程序中使用的FIND命令:

FIND "Msg" "%CUR_DIR%\testoutput.txt" > NUL 
if %errorlevel% 0 (
echo "inside if"
"%CUR_DIR%\ErrorCheck.exe" "%CUR_DIR%\testoutput.txt" "Msg" >>%LOG_FILE%
SET RET_VALUE=1
)

文件testoutput.txt包含一些数字和一些带有0的记录。运行FIND命令时出现以下错误: 此时0意外。

请帮助您删除错误。

1 个答案:

答案 0 :(得分:0)

我解决了上述错误。在下面的代码中:

FIND "Msg" "%CUR_DIR%\testoutput.txt" > NUL 
if %errorlevel% 0 (
echo "inside if"
"%CUR_DIR%\ErrorCheck.exe" "%CUR_DIR%\testoutput.txt" "Msg" >>%LOG_FILE%
SET RET_VALUE=1
)

我将%errorlevel%0更改为%errorlevel%NEQ 1,因此代码如下所示:

FIND "Msg" "%CUR_DIR%\testoutput.txt" > NUL 
if %errorlevel% NEQ 1 (
echo "inside if"
"%CUR_DIR%\ErrorCheck.exe" "%CUR_DIR%\testoutput.txt" "Msg" >>%LOG_FILE%
SET RET_VALUE=1
)