Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
296 views
in Technique[技术] by (71.8m points)

windows - Best way to view a command return code in DOS

Sometimes I run a command in cmd such as:

fc /b file1 file2

and would like to see the return code from fc. Is there a simple way to do this?

question from:https://stackoverflow.com/questions/2521818/best-way-to-view-a-command-return-code-in-dos

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
echo %ERRORLEVEL%

From TechNet, Command shell overview: "%ERRORLEVEL% ... Returns the error code of the most recently used command. A non zero value usually indicates an error."

To test for specific error levels in batch files, you may find this knowledgebase article useful.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...