Yeah, DOS ERRORLEVEL can be somewhat of a pain...
I've not found a reliable way to actually get the value in a .BAT, only test
it with "if errorlevel ..."
In the past I'd written some tools to help:
-An EXEC tool which would run the program and then store the returned
exit code in a known/accessible place (like in a file on my RamDrive or in
an environment variable).
- I also wrote a tool to find where in DOS memory the value was being stored,
and be able to retrieve it. The main problem with this is that it's not a
documented DOS "feature" and could move from version to version. So I had to
run the scan ever time I changed DOS versions.
Alas, both of these are "long gone" - the first was easy and it would be
fairly trivial to recreate.
IIRC, the second was a lot more work - it has to execute itself with a command
line option causing it to return a specific exit code -- run itself with an certain
exit value, then scan DOS memory to see what locations have that value - repeat
with different values until you can narrow it down to one location!
* I also doubt this would work in DosBox as unlike true DOS DosBox stores some things
in memory not accessible to the virtual machine *
I do still have one tool I sometimes use when working with ERRORLEVEL:
ERRLVL number <- Exits with the specified exit code
ERRLVL program ... <- Runs the named program with it's arguments, then shows
the exit code it returned.
If program does not have an extension, tries .BAT, .COM and .EXE
If it doesn't specify a directory, walks your PATH looking for it.
I can certainly make this available if it would help!
Dave
Dave ::: https://dunfield.themindfactory.com ::: "Daves Old Computers"->Personal
Dave ::: https://dunfield.themindfactory.com ::: "Daves Old Computers"->Personal