Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 416
  • Last Modified:

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

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
lourson
Asked:
lourson
  • 3
  • 3
  • 2
1 Solution
 
gmayoCommented:
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
 
gmayoCommented:
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
 
loursonAuthor Commented:
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!

 
loursonAuthor Commented:
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
 
Wim ten BrinkCommented:
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
 
gmayoCommented:
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
 
Wim ten BrinkCommented:
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
 
loursonAuthor Commented:
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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

  • 3
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now