从批处理文件设置错误级别 [英] Set errorlevel from batch-file
问题描述
我正在研究这种复杂的(对我来说)自动化,其中一部分是从另一部分开始(未调用)的批处理脚本.
现在,所有这些工作都在进行中,我希望能够用一条简单的指令替换Started批处理脚本,该指令可以使Start-ing脚本在启动子脚本之后具有:
%ERRORLEVEL%EQU 1
(然后我可以处理错误处理方面和测试内容)
但是也有一些不错的东西,不会使系统处于不自然的状态(我可能会根据这种不良状态编写脚本,并想知道为什么当我组装所有组件时它们都无法正常工作).
因此,"Format C -q"不起作用! ;)
I am working on this complicated (for me...) automation and one part is a batch script Started (not Called) from another one.
Now, it's all work-in-progress and I'd like to be able to replace the Started batch script with a simple instruction that would do such that the Start-ing script, after having started the child script, has:
%ERRORLEVEL% EQU 1
(And then I could work on the error-handling aspects and test stuff)
But also something nice that doesn't put the system in an unnatural state (and I might script things according to that bad state and wonder why things don't work when I assemble it all).
So, "Format C -q" doesn't work! ;)
谢谢
推荐答案
cmd /c exit 1
会将错误级别设置为1
.
cmd /c exit 1
will set the errorlevel to 1
.
这篇关于从批处理文件设置错误级别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!