Solved

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

Posted on 2003-10-27
8
409 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
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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

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 Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

810 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