Solved

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

Posted on 2003-10-27
8
407 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
  • 3
  • 3
  • 2
8 Comments
 
LVL 8

Expert Comment

by:gmayo
Comment Utility
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
Comment Utility
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
Comment Utility
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
 

Author Comment

by:lourson
Comment Utility
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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 17

Expert Comment

by:Wim ten Brink
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
How to fill array with TArray.Create? 14 68
Simple Delphi Question 9 77
FMX enumerated colours 2 70
Run video youtube webbrowse 10 44
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now