Batch file help

Caporegime
Joined
22 Jun 2004
Posts
26,684
Location
Deep England
I'm trying to determine the return code of an executable using a batch file in Win2k. All I want to do is echo it to the screen.

I thought I'd just be able to do something like this:

Code:
myCommand.exe param1 param2
echo %errorlevel%

... but this doesn't seem to echo anything. Any ideas?
 

Nope :) Found a solution on the web in the end, for anyone interested it was:

Code:
echo off
myProgram.exe param1
IF ERRORLEVEL 3 GOTO label3
IF ERRORLEVEL 2 GOTO label2
IF ERRORLEVEL 1 GOTO label1
GOTO label0

:label3
set returnCode=3
GOTO end

:label2
set returnCode=2
GOTO end

:label1
set returnCode=1
GOTO end

:label0
set returnCode=0
GOTO end

:end
echo Return code is: %returnCode%

Not a very nice solution but it works and I know that myProgram.exe only has 4 possible return codes so it will do. I hate Microsoft.
 
Back
Top Bottom