Setting initial environment from Delphi GUI

I have a Delphi 3 program which creates a batch file based on selections made by the user.  I then use WinExec( ) to run the batch file.

The problem is, when WinExec opens the DOS Shell (in order to run the batch file) the DOS Shell does not have the correct initial environment size (4096 KB) needed for the batch file.

How do I programmatically set the initial environment so I don't get "Out of environment space" when I run the batch file?

Please...only submit comments for now.  If a comment works, I'll have you resubmit the comment as an answer.


Tom KnowltonWeb developerAsked:
Who is Participating?
MadshiConnect With a Mentor Commented:
Well, nice, that it works - and thanx for the points...   :-)

Regards, Madshi.
Try this one:

  WinExec('C:\Command.Com /E:4096 /C C:\YourPath\YourBat.bat');

Does that help?

Regards, Madshi.
I should think that you would be able to do this via the commandline parameters:

COMMAND [[drive:]path] [device] [/E:nnnnn] [/L:nnnn] [/U:nnn] [/P] [/MSG]
                       [/LOW] [/Y [/[C|K] command]]
  [drive:]path    Specifies the directory containing COMMAND.COM.
  device          Specifies the device to use for command input and output.
  /E:nnnnn        Sets the initial environment size to nnnnn bytes.
                  (nnnnn should be between 256 and 32,768).
  /L:nnnn         Specifies internal buffers length (requires /P as well).
                  (nnnn should be between 128 and 1,024).
  /U:nnn          Specifies the input buffer length (requires /P as well).
                  (nnn should be between 128 and 255).
  /P              Makes the new Command Interpreter permanent (can't exit).
  /MSG            Stores all error messages in memory (requires /P as well).
  /LOW            Forces COMMAND to keep its resident data in low memory.
  /Y              Steps through the batch program specified by /C or /K.
  /C command      Executes the specified command and returns.
  /K command      Executes the specified command and continues running.

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Tom KnowltonWeb developerAuthor Commented:
Madshi / edey:

I will try your suggestions.  Madshi's response looks like the one I want.

Tom KnowltonWeb developerAuthor Commented:

Resubmit your comment as an answer, please.  Your comment was exactly what I needed.  Geez...I was *that* close to solving this myself.
Tom KnowltonWeb developerAuthor Commented:
No problem.  :)
This question was awarded, but never cleared due to the JSP-500 errors of that time.  It was "stuck" against userID -1 versus the intended expert whom you awarded.  This corrects the problem and the expert will now receive these points; points verified.

Please click on your Member Profile and select "View Question History" to navigate through any open or locked questions you may have to update and finalize them.  If you are an EE Pro user, you can also choose Power Search to find all your open questions.

This is the Community Support link, if help is needed, along with the link to All Topics which reflects many TAs recently added.
Thank you,
Moderator @ Experts Exchange
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.