Max Length of Command Line Arguments

What started out as an experiment,caught me by surprise in VS.The max length that i can pass to as a Command Line Arg is 4096 characters(4K).ie if i enter 11111…. 4196 times.After that Ting!

image

As i did my experiment in Win-7 this was the limit.More search on this topic led me to this Kb article.http://support.microsoft.com/kb/830473.

Summary:

1) If you run this application through command prompt:

If you are running Windows XP or later, the maximum length of the string that you can use at the command prompt is 8191 characters. If you are running Microsoft Windows 2000 or Windows NT 4.0, the maximum length of the string that you can use at the command prompt is 2047 characters.

Please refer to this page for more information: http://support.microsoft.com/kb/830473/en-us

2) If you run this application by CreateProcess():

See the description of lpCommandLine parameter:

[in, out] The command line to be executed. The maximum length of this string is 32K characters. If lpApplicationName is NULL, the module name portion of lpCommandLine is limited to MAX_PATH characters.

Please refer to this page for more information: http://msdn2.microsoft.com/en-us/library/ms682425.aspx

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s