R.Wieser
2024-04-03 16:51:22 UTC
Hello all,
I've got a program which does a "CMD /C {batchfile}", and I would like to
receive a value the batchfile exists with.
Not a problem, I just do an "exit {value}".
But I now have a few batchfiles, some of which could call another - one
which I can also execute directly. And that creates a problem :
When I run the batchfile directly the above "exit {value}" will propagate
down thru CMD.EXE into the program and I can see the {value}.
But when I call another batchfile which calls the above batchfile (as a
subroutine) that latter one will not return control to the former one, but
instead just terminates CMD.EXE. :-(
I found that I could use "exit /b {value}" (causing the called bachfile to
return control to the caller), but when used in the main batchfile that
{value} will not propagate down thru CMD.EXE
Question:
How do I tell CMD.EXE to accept the last "exit /b {value}" and return it as
its own exit value ?
Remark: I think I already have a *work-around* figured out, but if there is
a cleaner way to do it (replacing the "/b" argument with something else ?) I
would rather use that.
Regards,
Rudy Wieser
I've got a program which does a "CMD /C {batchfile}", and I would like to
receive a value the batchfile exists with.
Not a problem, I just do an "exit {value}".
But I now have a few batchfiles, some of which could call another - one
which I can also execute directly. And that creates a problem :
When I run the batchfile directly the above "exit {value}" will propagate
down thru CMD.EXE into the program and I can see the {value}.
But when I call another batchfile which calls the above batchfile (as a
subroutine) that latter one will not return control to the former one, but
instead just terminates CMD.EXE. :-(
I found that I could use "exit /b {value}" (causing the called bachfile to
return control to the caller), but when used in the main batchfile that
{value} will not propagate down thru CMD.EXE
Question:
How do I tell CMD.EXE to accept the last "exit /b {value}" and return it as
its own exit value ?
Remark: I think I already have a *work-around* figured out, but if there is
a cleaner way to do it (replacing the "/b" argument with something else ?) I
would rather use that.
Regards,
Rudy Wieser