----^--->
/\

//\\
//The\
/Sy
stem\
////
Guard
\

In the mount of the LORD it shall be seen. Genesis 22:14

ErrorCodes

Booming Or Fuming? | MasterCatalog | ntlib (FREE) | NTCmdLib | MtCmds | Scripts | Almost Free | TheGuardBook | Help

 

Library
Resources

Constants | Functions | GlobalSwitches | GuardNotes | Command Shorthand | MountCommands | Procedures

Guard
Notes

  ErrorCodes | SetCalc

!ErrorCodes

Description

How to list all Win32 Error Codes

Contents

When you encounter a numbered error code, you can get the (sometimes redundant) error description by typing

    Net HelpMsg [ErrorNumber]

Have you ever wondered how many of these codes there are?

Here's a short script to list them all.  We suggest you redirect the output to a file as it is quite large.

This script is parsed by the command interpreter as a single line of code using the "Cord Of Speed" described in Booming or Fuming? (see BoF-20030115 and BoF-20030122).

ListErrorCodes.cmd
(this script requires the Expert NT/2K/XP/K3 Command Library)

NT
2K
XP
K3
01.
02.
03.
04.
05.
06.
07.
08.
09.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
@(
   (
     
FOR /L %%X IN (0,1,9) DO @(
         %.ForAll% %%Y IN ('%.Net% HelpMsg %%X %.eKity%') DO @(
           
ECHO:0000%%X %%Y
         )
      )
   )^
   &(
     
FOR /L %%X IN (10,1,99) DO @(
         %.ForAll% %%Y IN ('%.Net% HelpMsg %%X %.eKity%') DO @(
           
ECHO:000%%X %%Y
         )
      )
   )^
   &(
     
FOR /L %%X IN (100,1,999) DO @(
         %.ForAll% %%Y IN ('%.Net% HelpMsg %%X %.eKity%') DO @(
           
ECHO:00%%X %%Y
         )
      )
   )^
   &(
     
FOR /L %%X IN (1000,1,9999) DO @(
         %.ForAll% %%Y IN ('%.Net% HelpMsg %%X %.eKity%') DO @(
           
ECHO:0%%X %%Y
         )
      )
   )^
   &(
      %.ifNotNT% (
        
FOR /L %%X IN (10000,1,99999) DO @(
            %.ForAll% %%Y IN ('%.Net% HelpMsg %%X %.eKity%') DO @(
              
ECHO:%%X %%Y
            )
         )
      )
   )
)

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.

K

E

Y

Common Commands INTERNAL External /SWITCH Parameter Help text AddonTool
Mounted Commands .Mount/\Command CmdShorthand #Constant $FUNCTION :Procedure !GuardNote
Operating Systems NT/2K/XP/K3 NT Only NT/2K 2K Only 2K/XP XP Only XP/K3 K3 Only 2K/XP/K3

Guard
Notes

  ErrorCodes | SetCalc

/\
//\\
//
The\
/Sy
stem\
////
Guard
\
COME ON UP WITH US!
and
Congratulations On Your Decision
to
RISE ABOVE
THE REST!

^
/
!\
/LIB\

TheSystemGuard.com [Revised: 2007-03-29]
Copyright © 1995-2007, JWC
Computer Communications,
All Rights Reserved, Worldwide.
 Disclaimer       Privacy       About Us       More


Communication Is Business!

We Master It With Knowledge!

^
/
.\
/M^C\