I\'ve got truncated parameters when passing very long file paths. I need to start a program and pass it everything via command params - sometimes it just truncates the command.
How to work around the limitation To work around the limitation, use one or more of the following methods (as appropriate to your situation):
- Modify programs that require long command lines so that they use a file that contains the parameter information, and then include the name of the file in the command line.
For example, instead of using the ExecutableFile.exe Parameter1 Parameter2 ...ParameterN command line in a batch file, modify the program to use a command line that is similar to the following command line, where ParameterFile is a file that contains the required parameters (parameter1 parameter2 ...ParameterN):
ExecutableFile.exe c:\temp\ParameterFile.txt
- Modify programs that use large environment variables so that the environment variables contain less than either 2047 or 8191 characters (as appropriate to your operating system).
For example, if the PATH environment variable contains more than either 2047 or 8191 characters (as appropriate to your operating system), use one or more of the following methods to reduce the number of characters:
- 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.
- Investigate possible methods that you can use to reduce the dependency of PATH for locating .dll files.
that is from Microsoft Support, so nothing helpful for me - it seems that this limit cannot be increased and there is no way to run it in any other way...
What I'll try to do is: Remember the path to each file, move them to some DIR and then run program with CurrentDirectory set to DIR and just pass in the file names and after program has ended move the files back to their place - ugly, ugly, ugly, I know, but it seems that there is no other way...
I'm not sure what your question is, but there is a limitation on the commandline. This same limitation will be valid for Process.Start(command,args)
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.