The first section (02-08) contains two
FOR
loops. Line 03 loops from 0-9 by 1's and places the value in variable
%%X. Line 04 is run once for each number output by the first loop (in
this case, a total of ten times). The
.ForAll command places an entire line of
output into the variable %%Y.
%.Net% is the
ExactName MountCommand for Net.exe.
HelpMsg is a modifier for Net.exe
%%X is a number from Line 03
%%Y is the text of the Error Code output by Line
04
%.eKity%
suppresses any error messages in case a code is undefined
So the command inside the ()'s expands to, for example
C:\Windows\System32\Net.exe HelpMsg 0 2^>NUL
Finally, Line 05 displays the output as
00000 The operation completed successfully.
Lines 08-09 chain section 1 to section 2. In a similar fashion, lines 15-16,
22-23 and 29-30 link together the remaining sections. This chaining causes the
command interpreter to read the entire script in one gulp.
Note that Line 31 ensures that the last section is not run on Windows NT machines since their highest Error Code is usually below 10000.
If this isn't the case for you, or if you simply want to remove this condition, delete lines 31 and
37.
Here's some sample output from this script (these are large text files). The file naming pattern is
%#OS%.%#Role%.SP%#ServicePack%.ErrorCodes.txt
which produces file names like
2K.Server.SP4.ErrorCodes.txt
Click one of the following to see the output of ListErrorCodes.cmd.
|