Windows command-line length limitation (was Re: is perl better?)

Thomas Heller theller at python.net
Fri Mar 5 13:38:30 EST 2004


>> the total string is 6809 characters long.
>
> This is likely far too long for the Windows command line, but perhaps
> 2000 is more sophisticated than I would expect...
>
>> I do not know the allowed character length (I am using windows 2000)
>> but perl just runs the command fine, whereas python results in
>> The following character string is too long:

Just to throw in some real numbers, MSDN knowledge base article 830473
<http://support.microsoft.com/default.aspx?scid=kb;en-us;830473>
says:

"""
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.

This limitation applies to the command line, individual environment
variables (such as the PATH variable) that are inherited by other
processes, and all environment variable expansions. If you use Command
Prompt to run batch files, this limitation also applies to batch file
processing.
"""

Read the article to found out more (but not much more).

BTW: The workarounds that the article mentions sound more like the old
MSDOS days than like a modern operating system.
Ridiculous examples:
        # Use shorter names for folders and files.

        # Reduce the depth of folder trees.
        
        # Store files in fewer folders so that fewer folders are
        # required in the PATH environment variable.

Thomas





More information about the Python-list mailing list