Windows Explorer Context Menu

Alex K. Angelopoulos aka at mvps.org
Fri Dec 13 05:33:12 EST 2002


None of those things will directly allow you to pass a longer command line
AFAIK -  likely including the DDE workaround, unfortunately. :(

The reason is that the command tail length limitations for Windows (which tops
out about 2046 characters for 2000/XP and I think NT4) is actually a general
shell execution limit. In fact, it translates drag-drop sets into a command line
including quoted and space filenames (which kills an extra 3 available
characters for each file dropped).  If the drop target is not a true executable
but is a script or other interpreted document with a binary behind it, the
explicit command line will also include the full path to it prepended before
script/document.

If you exceed the path length possible, it doesn't even get to the file; you get
an error similar to this:

"Windows cannot access the specified device, path, or file.  You may not have
the appropriate permissions to access the item."

Here are some workarounds.  None are great, unfortunately:

(1) If you really need to cram in things and nothing but shell drag-drop will do
it for you, move the utilities (or front-end scripts which call them with all
files sequentially) into a relatively shallow path.  Put the files into a
shallow path as well and give them short names.  This will probably still leave
you with a maximum of 100 or so files you can drag-drop.  This is probably more
bother than it is worth.

(2) Iteration over a folder.
 One way to do this is to drop the parent folder of files you want to process,
and have a script just iterate over the contents.  If some are already
processed, you can probably flag them in some way so they are not re-processed.

(3) Dynamic collection building.
Here's a way I've used in the past, if I have a master script I want to run
against a lot of files but I want to batch-process them all.  I have another
script that does nothing but act as an instant droptarget; I drop handfuls of
files onto it, and it writes the paths to a special "build target" file.  When I
am ready to go, I drag-drop the build file onto the master script; it uses a
generic routine to grab the content, deletes the build target file, parses the
data into filenames, then processes each one in turn.

All of them are annoying workarounds.

-- 

"R.Marquez" <ny_r_marquez at yahoo.com> wrote in message
news:8a27e309.0212041347.27d0284a at posting.google.com...
> I have been using the "Send to" Context menu of Windows Explorer to
> pass files as parameters to some small utilities I've written.
> However, the "Send to" functionality appears to have a predefine
> allowable size for the parameters it passes.  So the deeper the path,
> the less the number of files it can pass without complaining.
>
> So, I am trying to move on to another method of getting the selected
> files as parameters, from Explorer.  I have dug around for a few
> hours, and it seems that I have two options:
>
> 1) Somehow getting the files from Explorer through DDE (I have no idea
> where to start on this yet).
>
> 2) Writting a context menu extension dll. (I don't think I can do this
> with Python, can I?)
>
> Python is my first (programming) language, and so far have had no need
> (nor desire :) to learn another one. So, right now, I feel a little
> stuck, and I was wondering if anyone has some suggestions on how to
> accomplish what I need.  As allways, any effort in responding is much
> appreciated.
>
> -Ruben





More information about the Python-list mailing list