You too can use your psychic powers: Spaces in paths

I’m going to be lazy today and make you solve the problem.

Did a recent security hotfix change change the way we handle UNC paths with spaces? Normally, if we open the Run dialog and type \\server\share\Support Library\, the Support Library folder opens. But recently it stopped working. Instead of opening the Support Library folder, we get the Open With dialog:

Open with

Choose the program you want to use to open this file:

File: Support

  Contoso Chess Challenger 5.0
  Contoso Music Studio
  Fabrikam Chart 2.0
  Litware 2010
$   Woodgrove Bank Online
  Happy Holidays!
  Always use the selected program to open this kind of file


Can you figure out what happened recently that introduced this problem? You have all the information you need.

Comments (29)
  1. A file named "Support" was created on "share".

  2. Denial ain't a river, bub says:

    Happy Holidays to you too, Raymond!

  3. Jeffrey Davis says:

    I like how the dialog box actually works. :)

  4. Jake says:

    A remote file named Support was added to the \servershare folder?

  5. ^^ What alegr1 said and they didn't use quotes. :D P.S. I wish Windows 8 had the 'classic' Open With dialog. The new Open With dialog (…/Open+With.png) breaks the NoInternetOpenWith and NoFileAssociate Group Policies (due to another decision to remove programmatic file associations). It is a Metro-style floating dialog that looks out of place on the desktop. And browsing for a program not listed in it requires lots of clicks and scrolling and its keyboard usability is broken.

  6. Maurits says:

    The "File: Support" kind of gives the game away :-)

  7. Joshua says:

    Butt out xpclient. We know the Windows shell is as good as dead but MS hasn't figured it out yet.

  8. @Joshua, I hope you're kidding. If the old Windows Shell was dead, there wouldn't any improvements to it in Windows 8 like Undo New Document or UAC overlay shield on taskbar pinned icons set to run as admin. :)

  9. Antonio Rodríguez says:

    Please don't feed the troll. Even if it (he) is almost a pet here :-) .

    [Insert obligatory compliment about how good Raymond is recreating arbitrary dialog boxes in plain HTML]

  10. Leo Davidson says:

    In this case, I think the real troll is the Windows 8 Open-With dialog. There are so many things wrong with it that it's difficult to know where to start, and hard to imagine it turned out so bad by accident. I honestly thought my Windows 8 install or VM drivers were malfunctioning the first time it appeared. :)

    Merry Christmas, everyone.

  11. Lawrence says:

    I love it how when Raymond is claiming to be 'lazy' he still creates a fully-functional dialog box that works across all browsers.

  12. Chunky Ks says:

    Bonus point, how it happened: What probably happened is someone with write/create privileges tried to open that file in a program that doesn't understand spaces.

  13. Yasunori says:

    The Windows 8 Open-with dialog really is a shocker.

  14. bhind says:

    it is not important,but…

    "Support" file has no extension,so "Always use the selected program to open this kind of file" is grayed out,isn't it?

    happy holidays too!

  15. j b says:

    Chunky Ks:

    Note that \servershareSupport Library is a directory, not a file, and opening av "Support Library" directory (or one of the files in it) for write is a rather uncommon operation.

    Nevertheless, your explanation may very well be the explanation of how the file came to life. (I probbly would never have thought of that myself!)

  16. Alternate Brian says:

    Came to give props on the functional dialog boxes even in g-reader, but I see the topic was already covered.  So let me just add in another.  That's some top-notch blogging, Mr. Chen.

  17. Jeffrey Bosboom says:

    It's a nice dialog box, but perhaps the 'Browse' button could be hooked up to open a file chooser dialog?

  18. Cesar says:

    @bhind: haven't used Windows for a while, but doesn't it hide file extensions by default? The "Support" file might in fact be "Support.ext", but the ".ext" is hidden unless the user knew the secret incantation to disable hiding file extensions.

  19. Neil says:

    So, I clicked on of the dialog "buttons" and now the site wants me to enter a comment… perhaps the buttons should have been given type="button" (or perhaps type="reset" in the case of the cancel button?) Nice use of Unicode characters in the "listbox" though.

    @bhind: Good catch! The first thing I noticed was that it wasn't checked, because the first thing I do when I get the "Open With" dialog is to uncheck that option.

    @Cesar: It's possible I guess, but it would have to be one of those rare known extensions without a handler. (And not including .DLL or .SYS either, as they prompt a special warning.)

  20. bhind says:

    (why doesn't my post show up?)

    @Cesar,I thought so, but Explorer option is "Hide extensions for known file types". if the extesion is hidden, we can't get Open With dialog.

    I tried this(windwos 7).

    1. enable "Hide extensions…"
    2. open command prompt.type "echo aa > test.ext"

    3. type "start test.ext"

    it shows filename with extension ".ext".but… shows "windows cannot open this file" dialog…um why?

  21. grahamesd says:

    So Windows thinks something is there.  Yet we know that "Support" doesn't exist, it's just the first part of the folder or share name.  Yet we didn't get the "Windows cannot access "\servershareSupport" which is what I would have expected.

    So I'm guessing that the first step in responding to the Run request, the step of parsing the string "\servershareSupport Library" worked, because Windows didn't complain that "Support" wasn't accessible or that it didn't exist. so therefore it found something and the thing I'm guessing it found was "Support Library".  

    The next step is for Windows to figure out what to do with what it found.  So the parsing by that step failed and instead of just opening the folder "Support Library", it thought it had to open a resource called "Support" and it couldn't find an associated app (no association to no extension) so it brought up the "Open With" dialog so the user could decide.

    So either the parsing on step 2 failed or step 1 screwed up the name when passing it to step 2.

    That's my guess.  I hope I'm somewhere in the ballpark.

  22. Falcon says:

    @grahamesd: But we DON'T know that "Support" doesn't exist – the question made no mention of that fact. Before such a file was created, Explorer found that it did not exist and continued the parsing process by treating the rest of the string (there are no more spaces until the end) as a path, found the "Support Library" folder and opened it. Then, one day, the "Support" file somehow got created, so Explorer tried to execute "\servershareSupport" with "Library" as an argument.

    Maurits mentioned the "File: Support" clue in the dialog, which I initially missed, but managed to figure out the problem anyway.

  23. Jeff says:

    IMO, the Run dialog (and the ShellExecute/CreateProcess/etc APIs) should have just required quote marks around a filename with spaces in it, so it would never be ambiguous where the filename ends. I hate software that tries to be "smart" and does what it thinks I want (unpredictably), rather than just doing what I say (predictably).

    [In other words, "IMO, Windows NT should have been allowed to fail with the consolation that it was able to maintain its purity of design all the way to the grave. -Raymond]
  24. Ian Yates says:

    I've caused this problem myself in the same sort of folder (a share where I stick all of my various downloads).  I want to download a new SQL cumulative update and store it on my NAS at \domain.localdatadownloadsSQL Server2012RTMCU4 (DFS shares rock!)

    Note the sapce in "SQL Server".

    Rather than browse there in IE's "save as" box, I just hit Win+R and type cmd (ie, bring up a command prompt) and then type "md " followed by the path I wanted to make (pasting it in usually).  If I forget the quotes, I make a folder called "SQL" in the downloads share PLUS another folder tree starting with Server, then a nested folder in there called 2012, etc.

    This is all so I can then paste the same path into IE's save as window and hit enter.  It sounds long-winded but it's actually quite fast and all keyboard based.  I usually use Win+R's textbox as the scratch space to populate the clipboard with the path I want so I can paste it into the just-created command prompt and also into IE.

  25. Don Benson says:

    Did somebody create a runnable file called "support" in the share folder? Now "library" is interpreted as a command line argument.

  26. Oh dear, I've been relying on Run getting the spaces right without thinking about the ambiguity for years.  Then again, whenever I type something without quotes the first thing I check if there is an error is the quotes not being there.

  27. Adam Rosenfield says:

    @Jeff: A big part of the problem is that the original kernel interface (harking back to the days of WinExec) accepted the command line as a single flat string instead of an array of strings, like Unix's argc/argv in the execve(2) interface.  With a string array, the kernel never has to do any parsing because there's no possibility of ambiguity—if a program wants to start another program with a space in an argument, then by golly it puts a space in that argument.

    But that decision to pass the command line as a single string was set in stone a long time ago, and until Microsoft perfects its time machine, we're stuck with it.  As Raymond said, the pragmatic thing to do for backwards compatibility's sake is to have the kernel parse the command line in more than one way until it finds a matching executable.

  28. NT says:

    Since last time it worked, someone created the file "\servershareSupport", possibly by doing something careless like (unquoted) "copy \servershareSupport Library" in the shell.

  29. Matt says:

    @Adam: The kernel doesn't do any parsing of your command line string. All of that parsing nonsesnse is done by libraries in user mode.

Comments are closed.