运行批处理文件时找回的7-Zip的错误 [英] Retrieve an error of 7-zip when running a batch file
本文介绍了运行批处理文件时找回的7-Zip的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个批处理文件中,我执行以下命令行来列出归档的内容:
I have a batch file in which I execute the following line to list the contents of an archive:
"\Program Files\7-Zip\7z.exe" l "\Backup Google Docs.7z"
归档故意损坏。
cmd.exe的显示这样的:
cmd.exe displays this:
在同一批处理文件,执行以下,如何测试,有单词错误或不?
At the same batch file, following the execution, how to test that there is the word "error" or not?
推荐答案
所有程序的退出code存储在%ERRORLEVEL%
在批处理脚本变量。
Any program's exit code is stored in the %ERRORLEVEL%
variable in a batch script.
从7-ZIP手册:
7-Zip returns the following exit codes:
Code Meaning
0 No error
1 Warning (Non fatal error(s)). For example, one or more files were locked by some other application, so they were not compressed.
2 Fatal error
7 Command line error
8 Not enough memory for operation
255 User stopped the process
所以:你可以这样做:
So: you can do:
"\Program Files\7-Zip\7z.exe" l "\Backup Google Docs.7z"
if errorlevel 255 goto:user_stopped_the_process
if errorlevel 8 goto:not_enough_memory
if errorlevel 7 goto:command_line_error
if errorlevel 2 goto:fatal_error
if errorlevel 1 goto:ok_warnings
注意,如果
检查,因此,你应该把他们按降序排列。%ERRORLEVEL%
大于或小于N等于错误级别ñ
Caution, if errorlevel N
checks that %ERRORLEVEL%
is greater or equal than N, therefore you should put them in descending order.
这篇关于运行批处理文件时找回的7-Zip的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文