home bbs files messages ]

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,764 of 68,980   
   Zaidy036 to R.Wieser   
   Re: Returning a value from a random batc   
   04 Apr 24 12:10:32   
   
   From: Zaidy036@air.isp.spam   
      
   On 4/3/2024 12:51 PM, R.Wieser wrote:   
   > 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   
   >   
   >   
   One way is to use SETX which provides an environmental variable for   
   another batch to read.   
      
   --- 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