none
Command Line Parameters - Length Limitation RRS feed

  • Question

  • I've created an application that consists of one program (.prg) that opens with a Parameter statement containing 10 parameters. The parameters are intended to be file names. I've put the .exe of the program into the Send To folder in Windows, and when I right click on a file name in Windows Explorer and send it to my application, the highlighted file is copied to a different location.  This works fine for multiple selected files up to 10 files (i.e. each highlighted file becomes a parameter on the command line of the program) and the program operates on all of the selected files. EXCEPT that if the total number of characters in the command line exceeds 128, it truncates it and it doesn't continue. Since the full path of each file is part of the file name, I am often limited to two or three files at the same time. 

    Question: Is this a Windows or a VFP limitation? Is there any way to tweak the Registry or otherwise to get around this?

    Thanks.

    Jason

    Tuesday, February 15, 2011 12:53 PM

Answers

  • You are mentioning neither VFP nor OS version but the limitation exists for sure.

    Windows Vista allows command line up to approx. 256 characters (incl. path and exe name) and this is the main limitation to pass parameters this way. VFP 9 allows almost unlimited parameter size from this point of view.

    If you really need to process files this way then you have to find another way how to identify files selected in some folder.

    • Marked as answer by Calvin_Gao Tuesday, February 22, 2011 10:52 AM
    Tuesday, February 15, 2011 2:12 PM
    Moderator
  • For OS: maximum command line lenght is 32767 characters (this limit is from unicode string structure), command prompt maximum lenght is 8192 characters (this limit is from cmd.exe). You may also check:

    http://support.microsoft.com/kb/830473

    For Vfp: maximum characters per command line are 8192

    http://msdn.microsoft.com/en-us/library/aa975385(v=vs.71).aspx


    dni
    • Marked as answer by Calvin_Gao Tuesday, February 22, 2011 10:52 AM
    Tuesday, February 15, 2011 2:31 PM
  • command prompt maximum lenght is 8192 characters

    This is true but how could you explain the maximum passed parameter length dependence on the EXE path length when you are creating a shortcut in Windows?

    OTOH, FoxPro limitation must also exist because standard C console application can process parameters of almost unlimited length passed from cmd.exe and FoxPro application executed via ShellExecute can handle parameter up to 247 characters long. When you pass 248 characters then executed application reports an (VFP) error...

     

    • Marked as answer by Calvin_Gao Tuesday, February 22, 2011 10:52 AM
    Tuesday, February 15, 2011 3:28 PM
    Moderator

All replies

  • You are mentioning neither VFP nor OS version but the limitation exists for sure.

    Windows Vista allows command line up to approx. 256 characters (incl. path and exe name) and this is the main limitation to pass parameters this way. VFP 9 allows almost unlimited parameter size from this point of view.

    If you really need to process files this way then you have to find another way how to identify files selected in some folder.

    • Marked as answer by Calvin_Gao Tuesday, February 22, 2011 10:52 AM
    Tuesday, February 15, 2011 2:12 PM
    Moderator
  • For OS: maximum command line lenght is 32767 characters (this limit is from unicode string structure), command prompt maximum lenght is 8192 characters (this limit is from cmd.exe). You may also check:

    http://support.microsoft.com/kb/830473

    For Vfp: maximum characters per command line are 8192

    http://msdn.microsoft.com/en-us/library/aa975385(v=vs.71).aspx


    dni
    • Marked as answer by Calvin_Gao Tuesday, February 22, 2011 10:52 AM
    Tuesday, February 15, 2011 2:31 PM
  • command prompt maximum lenght is 8192 characters

    This is true but how could you explain the maximum passed parameter length dependence on the EXE path length when you are creating a shortcut in Windows?

    OTOH, FoxPro limitation must also exist because standard C console application can process parameters of almost unlimited length passed from cmd.exe and FoxPro application executed via ShellExecute can handle parameter up to 247 characters long. When you pass 248 characters then executed application reports an (VFP) error...

     

    • Marked as answer by Calvin_Gao Tuesday, February 22, 2011 10:52 AM
    Tuesday, February 15, 2011 3:28 PM
    Moderator