Solved

What is the max length of a string parameter an exe is able to accept

Posted on 2003-10-27
8
412 Views
Last Modified: 2010-04-05
Hello,
As you can see it, everything is in the title. I just need to know what's the maximum size of the parameter given to an exe for it's execution. Does anyone know?
Thx

lourson
0
Comment
Question by:lourson
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
8 Comments
 
LVL 8

Expert Comment

by:gmayo
ID: 9629756
A quick google suggests the following: nobody knows. In any case, it functions with null terminated strings and various webpages say anything from 1k to 32kbytes. Only one way to find out - try it!

Geoff M.
0
 
LVL 8

Accepted Solution

by:
gmayo earned 250 total points
ID: 9629801
Quick test program: about 880 characters. Could be limited by Delphi. This is running on XP Home, could be different on different OSs.

Geoff M.
0
 

Author Comment

by:lourson
ID: 9629877
Hi!
Thank you for answering so fast, am very impressed by your interest. I'm agree with you when you say that the best thing to do is tying. I'm under delphi7 on XP OS so i will try and then probably have an answer. But it will only be the XP case. What i'm wondering is : "does this length may vary between all the releases of µSoft from 98 to XP, via Me and 2000?". The app i'm writing will turn under any of those OS. Actually, i don't have the possibility to install all of those system for testing that. What i project to do to avoid avoid bad surprises is to write a temp file containing the wanted parameter and give its path in the command line, so the exe will take in charge the opening of the temp file. But I'd like to avoid this solution. it seems too ugly.
lourson.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:lourson
ID: 9629912
Ooops,
while writing a comment, you had already posted another answer (I'm a little bit slow, english is not my language). Our questions are the same. Does the OS or compiler influence this length? Well 880 chars is not enough yet, so i will have to use the parameters file solution.
I think the points are yours because of the big interest you gave me and the 880 chars detail. Congratulations.
 
0
 
LVL 17

Expert Comment

by:Wim ten Brink
ID: 9635026
Oops. Too bad you were a bit impatient... :-(

The length of the commandline is related to the size of the environment block. Old DOS users might still be familiar with the environment. You know, that stuff where you store the Windows 'path' variable and other info. Normally this is about 2048 characters and a normal Windows installation will eat up around 1200 characters. Thus you 'only' have around 800 to 900 characters left...
For more information about the environment, visit http://www.gscit.monash.edu.au/students/helpdesk/howto/msdos_env_space.html

Now, I'm not sure if NT/W2K/XP has the same limitation. But I think the limitation still exists. Basically, if you have to send over that many information to another application then it's better to use a parameter file instead like you yourself suggested.
0
 
LVL 8

Expert Comment

by:gmayo
ID: 9637171
Too impatient? He got an answer of "about 880" and your answer is "around 800 to 900"...... hmmmm!!! Now, as for "not sure if NT/W2K/XP has the same limitation", as already stated, this was on XP Home.

Geoff M.
0
 
LVL 17

Expert Comment

by:Wim ten Brink
ID: 9641252
Yeah, but you can enlarge the environment, thus allowing more than 900 characters. It could be possible to have twice or even more the amount of characters. I think the environment can be up to 32 KB in size, thus with one KB in use for settings, you could have a commandline of 31 KB. Theoretically...
0
 

Author Comment

by:lourson
ID: 9653676
Thank you gmayo and Workshop_Alex for your interest. I found very interesting the possibility to enlarge the environment. But unfortunaly 31 kb are still not enough for the use i project to do. In fact, the parameter i need to pass is an unlimited list of files '%' separated. So the parameter size may vary from a few byte to Megas. I'm sure now that I have to give up the parameter idea. I have to turn to the parameter file or table.
Just for information : Under XP Pro and D7, I reached a parameter string of ~2050. Above that, the app fails to launch.

Lourson
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Reconfigure Delphi Install? 2 76
How to add columns to a RAD Studio FMX grid at design time 1 59
Typecasting TBytes to Integer in Delphi XE8 2 67
TAction.OnAfterExecute? 2 31
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question