Re Wengier:
People nowadays collect a lot of valuable materials, but study little of them. Many people only come to the forum to ask when they actually need something. So the spread of information does not lie in whether it is public, but in whether the audience has the desire to learn about it.
Re Roy:
What Wengier said is quite right: errorlevel is used as an if command branch. Even under 98 and xp I have never seen this environment variable. And if this ERRORLEVEL were an environment variable, then this program itself would lose its meaning, because the purpose of the program is to assign the ERRORLEVEL value to an environment variable. Even if we assume Leonardo Pig was using it as a variable, then he should have used ==; otherwise it would be a syntax error. So here we can be sure he was using it as a command branch.
And when used as a command branch, the relationship between ERRORLEVEL and value should be greater than or equal to, not equal, so that is why I said = is somewhat misleading. Then why can = still be used? Because ERRORLEVEL and value are originally separated by a space, and the DOS command line ignores a single = when parsing. This is the same as ; and a space. If you don't believe it, you can do a test.
::test.bat
echo First:%1
echo Second:%2
c:\test 111 222
c:\test 111;222
c:\test 111=222
Also, there are many characters in the DOS command line that get special interpretation. Everyone can test more of them. Redirect symbols are too familiar, so I'll skip them
※ Batchinger 致 Bat Fans:请访问
批处理编程的异类 ,欢迎交流与共享批处理编程心得!