1.

Solve : error level in batch file?

Answer»

can any one help me about error level in batch file.

I want to check whether the previous command is executed or not?
which errorlevel # returns this ?i have a list of errolevel # but what i want is not present in this list :

errorlevel0 :: No error
errorlevel1 :: Error opening file
errorlevel2 :: error reading file
errorlevel4 :: couldnot send message: SERVER response
errorlevel5 :: could not connect to server
errorlevel6 :: Fields TO(or CC/BCC) and from are requeried
errorlevel7 :: failed to initialize the windows sockets
errorlevel8 :: MFC initilization failed
errorlevel9 :: invalid port # , valid PORTS 0-65535
errorlevel10 :: File:"file specifice" too big to fit in memory
errorlevel16 :: failed to prepare email to sending
errorlevel17 :: could not save EML file to disk
errorlevel18 :: -TO required when using -SPLIT/_TOEACH parameter.the problem is sloved .

if the command executes it returns errorlevel = 0
and if it doesnot executed it returns errorlevel = 1
Quote from: roohi on September 19, 2008, 03:58:46 AM

the problem is sloved .

if the command executes it returns errorlevel = 0
and if it doesnot executed it returns errorlevel = 1


Not quite. Not all programs produce errorlevels. Errorlevels should be checked in reverse sequence and the actual check is for equal or greater than:

Code: [Select]if errorlevel 1 goto error
if errorlevel 0 goto success

There is also a VARIABLE %errorlevel% (cmd extensions must be on) which is treated as any other variable (ie: if %errorlevel%==1)

The errorlevels for MS commands are not standardized. XCOPY returns 0 if successful and anything from 1 to 5 if not successful.

the difference between this

1. IF errorlevel N command

and the Win2k and later alternative:

2. IF %errorlevel% EQU N command

is that 1 means "if errorlevel is N or greater then do command" whereas 2 means "if errorlevel is exactly equal to N then do command"THANKS for the explanation,
i meant by problem is sloved that for now my problem is resolved .
whatever thaks for the knowladge shared by you.


Discussion

No Comment Found