Rob van der Woude's Scripting Pages

User Output

Display Error Messages in the Local System Language

If your scripts have any error handling at all, you probably "hard coded" some error messages in your scripts.

Though there is nothing wrong with that, it might be a nice challenge to display error messages in the local system language.

You don't need to learn new languages to do so, nor will your scripts need to contain megabytes of error messages in several languages.
In Windows (and OS/2) there is a simple solution: NET HELPMSG (or NET HELP in OS/2).

The following Windows batch file will generate a tab delimited list of all available help and error messages in your local system language:

TYPE NUL > ErrorMsgAll.txt
FOR /L %%A in (0,1,0x4000) DO (
	FOR /F "tokens=*" %%B IN ('NET HelpMsg %%A 2^>NUL') DO (
		>> ErrorMsgAll.txt ECHO.%%A	%%B

To insert an error message in your batch file, just find a matching message text in the list (AllHelpMsg.txt), write down the number, and insert the following command in your batch file:


where nnnn is the error message number you just wrote down.



page last uploaded: 2016-09-19, 14:57