Forums before death by AOL, social media and spammers... "We can't have nice things"
|    alt.msdos.batch.nt    |    Fun with Windows NT batch files    |    68,980 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 68,762 of 68,980    |
|    R.Wieser to All    |
|    Returning a value from a random batch th    |
|    03 Apr 24 18:51:22    |
   
   From: address@is.invalid   
      
   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   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca