首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >findstr退出代码/errorlevel

findstr退出代码/errorlevel
EN

Stack Overflow用户
提问于 2015-08-04 21:41:19
回答 2查看 25.7K关注 0票数 12

我有一个使用findstr的程序,当找到字符串时,errorlevel返回0,当没有找到字符串时,errorlevel返回1。好的,没问题,我能处理好。

问题的症结在于,我找不到任何关于每个errorlevelfindstr意味着什么的官方文档。我需要知道findstr是否还有其他东西可以返回1errorlevel,或者当没有找到字符串时,它是否只返回1

如果有的话,最好是“官方”文档的链接,但如果有任何意见,我们将不胜感激。

提前感谢!

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2015-08-04 23:31:55

http://ss64.com/nt/findstr.html说:

代码语言:javascript
复制
FINDSTR will set %ERRORLEVEL% as follows:

0 (False) a match is found in at least one line of at least one file.
1 (True) if a match is not found in any line of any file, (or if the file is not found at all).
2 Wrong syntax 
An invalid switch will only print an error message in error stream.
票数 17
EN

Stack Overflow用户

发布于 2015-08-04 22:46:44

它记录在Dos 6.22的FIND命令的帮助中。

代码语言:javascript
复制
│FIND exit codes
│
│The following list shows each exit code and a brief description of its
│meaning:
│
│0
│    The search was completed successfully and at least one match was found.
│
│1
│    The search was completed successfully, but no matches were found.
│
│2
│    The search was not completed successfully. In this case, an error
│    occurred during the search, and FIND cannot report whether any matches
│    were found.
│
│You can use the ERRORLEVEL parameter on the <If> command line in a batch
│program to process exit codes returned by FIND.
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31810950

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档