How do I prevent users from dragging and dropping files in Explorer?


More than once, I've had a customer ask, "How do I prevent users from dragging and dropping files in Explorer?" Actually, three of them in the past year phrased it in an even more provocative way: "I want to write a program that hooks Explorer and displays a prompt before every drag/drop operation."

This is one of those cases where you have to figure out what the customer really wants. They've solved half of their problem and are asking you for help with the other half.

In my experience so far, when customers ask this question, their real problem is always one of the following:

First, they just want to prevent the user from moving files into or out of directories that the users shouldn't be modifying. In other words, the question isn't "How do I prevent users from dragging and dropping files in Explorer?" but rather "How do I prevent users from moving files I don't want them to move, and to prevent them from moving files into directories I don't want them to modify?"

The answer to the customer's real question is not to try to block the user interface operation (because, even if you block it there, they can still move the file around by other means, like say, the command prompt) but rather to apply ACLs to the underlying files and directories so that the users don't have permission to perform the operation you want to block.

Another common response to "Please explain why you think you need to do this" is "Well, I find that my users will accidentally move files around when they didn't mean to. They might be clicking on a file, but accidentally drag the mouse while clicking, resulting in the file being dropped into a folder by mistake." In other words, the real question is "How do I prevent users from performing accidental drag and drop operations?"

The answer to this customer's real question is to increase the mouse drag sensitivity (via System­Parameters­Info(SPI_SETDRAGWIDTH) and SPI_SETDRAGHEIGHT) to require uses to drag the mouse a "definitely not accidental" distance before the system considers a drag operation to be in progress. Depending on your users, you might crank this up to 10, 30, or even 60 pixels.

[Raymond is currently away; this message was pre-recorded.]

Comments (20)
  1. In case it got lost in the snarky comments in the linked article:

    http://www.parkscomputing.com/2009/04/windows-drag-sensitivity-utility/

  2. Emmanuel says:

    This article seems to bear a striking similarity to <a href="http://blogs.msdn.com/oldnewthing/archive/2009/04/10/9541813.aspx">a previous topic</a>.

    Still, no problem recapping stuff for the folks who haven’t read the whole archive ;-)

  3. Emmanuel says:

    My apologies; I did not realize that HTML comments are not allowed (though it makes sense).

    Correct URL from above:

    http://blogs.msdn.com/oldnewthing/archive/2009/04/10/9541813.aspx

  4. mikeb says:

    I think Raymond accidentally did a drag-n-drop copy of this article…

  5. Ian Boyd says:

    i was going to say, mikeb: "[Raymond is currently away; this message was pre-duplicated.]"

  6. Henke37 says:

    I think that a file must have accidentally been drag and drop copied to the backlog, twice.

  7. Alexandre Grigoriev says:

    Raymond, you mean "increase mouse drag threshold", which would *decrease* drag sensitivity (make it less likely to sense as a drag operation).

  8. Nick says:

    @Emmanuel

    You realize that Raymond himself linked that that blog entry at the end of this one, right?

    Drag-drop operations are actually an interesting aspect of usability I think because of how different cases become as you deal with older users. While I bet most of us here have had an issue or two where we accidentally created a copy of some files due to a drag/drop mistake, I know that working with several of the older faculty in my department that accidental drag/drop operations are very, very common.  The most common problem I see is when trying to double-click something, they’ll often drag the item a little resulting in moving a file to another folder, or messing up the Start Menu folders and icons, etc.

    Given the attention to detail that Microsoft usually gives things like accessibility, I’m kind of surprised there isn’t an official interface for this setting in the Mouse control panel.

  9. Masek says:

    Yeah, I agree with Nick about older users.

    But I’m not older and I have trouble with it more often than I would like.  Sometimes I click by accident while moving across the screen and move some file from one place to another, which is bad.  I would turn that feature off if I could.

  10. Jonathan says:

    The classic accidental drag-and-drop:

    1. Open a folder full of picture
    2. I want to select some of these picture, perhaps for mailing. So I CTRL-click one-by-one…

    3. Accidentally, I CTRL-click-and-drag one picture, creating a copy of all picture I’ve selected so far.

    4. I can’t pause to delete those, since I’d lose my selection. I continue…

    5. After I’m done, and this has happened several times, I have:

    PIC001.jpg

    PIC001 (1).jpg

    PIC001 (2).jpg

    etc.

  11. Worf says:

    Good thing Explorer has an Undo feature so accidental moves can be undone. Very useful if you were intending to move files and drop them in a different spot, and thus can’t find them. Undo, then repeat again.

    Now all Explorer needs is multi-level undo/redo.

  12. Marquess says:

    But this doesn’t address the following problem:

    * Pick up a file.

    * Drag it over a folder in the treeview.

    * Wait a tad to long.

    * Drop file a microsecond after the treeview expands, thereby dropping it into the wrong folder.

    * Optionally: Facepalm.

    And then there’s the problem with touchpads, which may not release the pointer when you thing they should.

  13. TomM says:

    Worf, the real problem is when you do an accidental drag/drop operation on a network drive because there is no undo in those circumstances. I’ve lost count of the number of times I’ve accidentally dragged a folder and dropped it somewhere I don’t know. More than once I’ve been looking for a folder I know ought to be somewhere and find that someone else has accidentally dragged it somewhere else.

    An ACL is no good here because the user DO have the rights do do these file operations (and may well need them), but it’s too easy to click too early while moving the mouse and do a drag and drop when you don’t mean to. You might not even be aware you’ve done it.

    I think windows really ought to either provide undo for operations on netword drives, or else confirmation dialogs on drag/drop operations on them.

  14. Marquess says:

    Well, I guess I should implement my own copy handler. <words type="famous" position="last">It can’t be that hard.</words>

  15. Nick says:

    @Marquess

    Good example.  I was hit by something similar the other day due to the new TreeView in Vista/Win7.  For whatever inexplicable reason,  they did away with a horizontal scrollbar in favor of a prescient sliding motion based on the position and motion of the mouse cursor.  I was trying to drag a file into a TreeView folder and about 5 milliseconds before I released the mouse button the control decided to slide way to the left resulting in a drop into a different folder.  I don’t complain often about NewWindows but the new TreeView is a pretty big WTF as a whole.

    @Worf

    Explorer’s undo feature has been a big help in the past, but one modification I’d love to see is a dialog box confirming the action to take (with more detailed information).  It’s been the case that I do some action before leaving work and then when I come in the next day I’ll accidentally hit the Undo command and have absolutely no idea what I just undid.  Using undo is uncommon enough (I think) that having a confirmation box say "Are you sure you want to undo the move of "file 1" from "folder 2" to "folder 4"?  Or something.

    (And no, I’m not just hating on NewWindows.  This is a blog post about user interface mistakes so it seems on-topic.  I think user interface design is interesting so I like discussing what people think works and what doesn’t.)

  16. Conor says:

    I can’t stand tap functionality on touchpad. After accidently dragging "My Documents" into "Windows" on one occasion (man slaps forehead!), turning tap off is the first thing I do on a new laptop.

    @Jonathan

    Using the keyboard, especially with large picture icons, is way more effective:

    Hold down ctrl, use the arrow keys to navigate around and tap the spacebar to select. I use my left hand to hold ctrl and tap spacebar and my right hand for the arrow keys. All very civilised! I use ctrl-x or ctrl-c, then switch to another window with the right folder and ctrl-v.

    Personally I don’t like drag and drop much. Maybe I’m an old Norton Commander guy (or just old), but I cannot handle the mouse for file operations. I use the keyboard all the time. It would be nice if I could "spindle" copy operations though (multiple ctrl-c like Word allows).

  17. After accidently dragging "My Documents" into "Windows" on one occasion (man slaps forehead!), turning tap off is the first thing I do on a new laptop.

    One more reason to run as a limited user.

  18. anonymous says:

    Why can’t I drag and drop to manually arrange files in Windows 7 Explorer? I hope MS fixes this in SP1.

  19. Marquess says:

    @Maurits:

    I think you missed the point there. Replace “Windows” by a directory where you do, in fact, have write permissions and re-evaluate.

  20. John says:

    Nick: There’s a redo command. If you know you just undid something, you can redo it.

    On XP (and earlier), when you hovered over Undo (or Redo) on the Edit menu, some useful information appeared on the status bar (such as "Undo move of ‘file.txt’" or somesuch.)

    On Vista and newer (once you turn the bar on) the information appears, but it’s empty, the names are missing most of the time, and it looks broken.

    It’s as if every new release has less and less attention to detail.

Comments are closed.

Skip to main content