Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

commandline argument parameter limitation

Language: C# I have to pass a huge string array (built dynamically) as an argument to run an exe. I am thinking of acheiving it by the below 2 ways. But I am not feeling confident.

  1. I can create it as one string delimited by spaces. I can invoke the exe through Process.Start. Hence the running child process considers the space and holds as a string array. However I am unsure about the string array limitation. Suppose if my string array count exceeds more than 10,000

  2. I can create it as one string delimited by a special symbol, which never fall in data. I can invoke the exe with the string. The running child process considers it as one single string, where i can split it with the same delimiter to get the string array back. However, here i am unsure about the command size. Will that do, if the command line string length is large

Can anyone help me in letting me know the parameter size limitations

like image 997
Muthukumar Palaniappan Avatar asked Feb 02 '12 15:02

Muthukumar Palaniappan


3 Answers

  • The limitation in Command prompt (Cmd. exe) is 8191. Command prompt (Cmd. exe) command-line string limitation
  • The limitation in c# code using Process is 32768 chars in win10.
  • Tested using Process.start()
like image 197
kim Avatar answered Sep 20 '22 16:09

kim


If you are passing 10,000 arguments to a program, you should be putting those arguments in a file and reading the file from disk.

like image 40
Icarus Avatar answered Sep 22 '22 16:09

Icarus


It depends on the OS:

See Command prompt (Cmd. exe) command-line string limitation on the Microsoft Support site.

On computers running Microsoft Windows XP or later, the maximum length of the string that you can use at the command prompt is 8191 characters. On computers 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.

(emphasis mine)

In regards to the size of a string array - if you have many millions of strings in a string array - you are mostly limited by the amount of memory available.

like image 44
Oded Avatar answered Sep 21 '22 16:09

Oded