Article View: alt.msdos.programmer
Article #1131Re: calling batch file from C prog
From: Matthew Busigin
Date: Tue, 01 Aug 1995 04:43
Date: Tue, 01 Aug 1995 04:43
48 lines
3044 bytes
3044 bytes
Dale Nurden (dalen@goofy.iaccess.za) wrote:
: In article <3q0107$j4p@news.iag.net>,
: jatmon@mail.iag.net (John R Buchan (jatmon)) wrote:
: > In article <D93H3A.tv@bashful.demon.co.uk>, root@bashful.demon.co.uk says...
: > >Im trying to call a batch file from the end of a C program, using either
: > >system, spawn?? or exec?? , and my problem is that although the batch file
: > >runs, it is given a copy of the parents environment, that is much smaller
: > >than it should be, and I am unable to ut any new environment variable in.
: > >
: > >Is the a way to force the batch file to be given the original environment,
: > >rather than a copy of it ???
: >
: > You could always call your program from a batch file and have the batch
: > file you want to run after the program as the next line.
: >
: > c:>copy con prog.bat
: > prog.exe
: > next.bat^Z
: It depends on what exactly he was having trouble with. This is certainly an
: option, but my guess is that he wants to be able to run a batch file and be
: able to set new environment variables, but then return to the original
: program afterwards. If this *is* what he wanted, then there is a solution.
: Say your environment is 1024 bytes long (set with COMMAND /E:1024) and of
: that 800 bytes is used (224 bytes free). The problem is that when you run
: the batch file with system() or whatever, the new instance of COMMAND.COM
: doesn't get the /E:1024 parameter (because system() doesn't specify it), so
: DOS assume you want the default 160 bytes. But because 800 are already in
: use, you get all 800 bytes without any extras. The result, you don't have
: those extra 224 bytes.
: The solution I use is a small TSR program I got from someone in this group
: (I can't remember who offhand - it's in the docs - sorry!) which basically
: fixes the problem. Don't ask how, it just does. I'll mail/post it if you
: like - I have the authors permission to do so.
: -Dale
: --------------------------------------------------------------------------------
: __|__ DALE M. NURDEN This is my NEW sig
: | Pinetown, South Africa Hope you like it!
: | dalen@goofy.iaccess.za (or dalen@iafrica.com, for some silly reason)
: ------------------------------ Hierdie sig is nie in Afrikaans beskikbaar nie --
--
Why can't you just take and system("Whatever.bat");
Technical Details
Message-ID:
<DCM7sz.EA1@icis.on.ca>Path:
arc1-ca.pugleaf.net!newshost.icis.on.ca!ht108References:
<D93H3A.tv@bashful.demon.co.uk> <3q0107$j4p@news.iag.net> <etznlG0d8L2I075yn@goofy.iaccess.za>Show Full Headers
Complete Article Headers
Newsgroups: alt.msdos.programmer,comp.os.msdos.programmer,comp.lang.c Path: arc1-ca.pugleaf.net!newshost.icis.on.ca!ht108 From: ht108@newshost.hometown.on.ca (Matthew Busigin) Subject: Re: calling batch file from C prog X-Nntp-Posting-Host: forest.hometown.on.ca Message-ID: <DCM7sz.EA1@icis.on.ca> Followup-To: alt.msdos.programmer,comp.os.msdos.programmer,comp.lang.c Sender: news@icis.on.ca (Newsie) Organization: Inter-Com Information Services X-Newsreader: TIN [version 1.2 PL2] References: <D93H3A.tv@bashful.demon.co.uk> <3q0107$j4p@news.iag.net> <etznlG0d8L2I075yn@goofy.iaccess.za> Date: Tue, 1 Aug 1995 04:43:47 GMT