Dos inline IF test for errorlevel, without use of Delayed Expansion

て烟熏妆下的殇ゞ 提交于 2019-12-06 08:23:46
Andriy M

One way is to use this older syntax:

%comspec% ... & if errorlevel 1 pause

In this case, a special variant of if statement is used, one that tests the current errorlevel state.

Another option might be this:

%comspec% ... || pause

The || command delimiter is roughly equivalent to & if !errorlevel! neq 0, i.e. the subsequent command is executed only if the previous one terminated with a non-zero exit code.

You could use conditional execution: reg.exe import c:\temp\test.reg || pause
|| means execute on failure (ie errorlevel neq 0).

You may may also want to try this example to see how it works:

find "this" && echo found || echo not found - it will inform you if 'this' was in input stream (entered from keyboard unless you redirect).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!