Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Returning a value to Dos

Status
Not open for further replies.

andrewclarke

Programmer
Dec 8, 2000
28
IE
I'm writing a simple console application to detect the windows version. I want to be able to use this from the command line.

I can display the version on screen, but how do I return it for use with errorlevel. I seem to be having a random value returned in errorlevel, no matter what I put in the 'return' value ie..

return(?);

Any help greatly appreciated.
 
Problem solved!

After checking the documentation on the 'IF ERRORLEVEL' batch command, it appears that the value returned from a C program does make it back to the batch file.

For reference,
When using IF ERRORLEVEL to check the return value in a batch file, the statement:

IF ERRORLEVEL 3 GOTO END

means:
If (errorlevel >= 3) then goto END

not:
If (errorlevel == 3) then goto END

A clear case of 'confessional debugging'!

Thanks anyhow.
:~/
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top