Jump to content

Command .bat files and return code


Recommended Posts

Guest Mario - Roma
Posted

I need to create a .bat file to performa some tests required by a third

party application.

The third party application documentation says that

"The script must exit with a 0 (zero) value to be considered

a success. Any other output results in failure. Upon success, the stdout

output of the

script will be examined."

I made some tests but I prseume I made some mistake.

Can anybody please explain how a .bat script must close in order to exit

with a 0 or a non 0 value and, maybe. provide some simple sample?

Regards

Mario

  • Replies 1
  • Created
  • Last Reply

Popular Days

Guest Pegasus \(MVP\)
Posted

Re: Command .bat files and return code

 

 

"Mario - Roma" <mario@mydomain.local> wrote in message

news:uyyl63CHJHA.2156@TK2MSFTNGP05.phx.gbl...

>I need to create a .bat file to performa some tests required by a third

>party application.

> The third party application documentation says that

> "The script must exit with a 0 (zero) value to be considered

> a success. Any other output results in failure. Upon success, the stdout

> output of the

> script will be examined."

> I made some tests but I prseume I made some mistake.

> Can anybody please explain how a .bat script must close in order to exit

> with a 0 or a non 0 value and, maybe. provide some simple sample?

> Regards

> Mario

 

Error levels (=return codes) are generated by each command included in your

batch file. The batch file itself returns the error level of the last

command you run. You can therefore force a zero error level by making the

last command a "safe" command, e.g. like so:

@echo off

"c:\Some Folder\Some Program.exe"

cd

 

Line 2 in this batch file might generate a non-zero error level. However,

since Line 3 generates a zero error level, the batch file will return a zero

error level too.


×
×
  • Create New...