36
10
Inspired by today's DailyWTF article.
The author claims that a file C:\Program.exe
would be executed when clicking on a shortcut to, for example, C:\Program Files\Doom 2\doom2.exe -nomusic
.
Supposedly, Windows first attempts to invoke C:\Program
with the arguments Files\Doom 2/doom2.exe -nomusic
.
If there is no C:\Program.exe
, it then tries C:\Program Files\Doom
with the arguments 2/doom2.exe -nomusic
.
And if there is no C:\Program Files\Doom.exe\
, it finally tries C:\Program Files\Doom 2\doom2.exe -nomusic
and succeeds.
This sounds like complete nonsense to me. I can't believe it ever worked this way. A commenter puts it well:
I find it hard to believe that any released version of Windows ever did the trial-and-error approach described by OP.
I absolutely believe that a released version of Windows had brain-dead behavior as a default. I have experienced it firsthand many, many times.
What I don't believe is that a released version of Windows had this brain-dead behavior, as described by the article. It's too huge a security flaw to have gone by unnoticed until some random Daily WTF submission uncovered it, at least a decade later since it would have had to be a version of Windows that predated XP.
Edit for clarity: Here's how I tested this myself.
- Copy notepad.exe to C:\program.exe
- Run C:\program files\Internet explorer\iexplore.exe
- Notepad opens. This is expected because it finds something called C:\program
- Move progam.exe to C:\program files\Internet.exe
- Run C:\program files\Internet explorer\iexplore.exe
According to the author of the article (and this article from Microsoft), notepad should still open. But it doesn't, the command fails with this message:
C:\program is not recognized as an internal or external command, operable program or batch file.
Again, I am not debating the article's claim that C:\program would be invoked. I am debating that Windows recursively tries every directory until it hits a match.
So, did any version of Windows ever work this way?
It seems like there's two (or more) separate questions going on here: would Windows allow you to create a shortcut to
C:\Program Files\...
, and would Windows interpret such a shortcut (or Run command, or command-prompt command, or some other method) as"C:\Program" Files\...
. The first part seems unlikely, but the second part seems probable and expected to me. – mwfearnley – 2016-06-07T10:59:45.877A third question, I guess, is: would any given Windows command-running method interpret
C:\Program Files
as"C:\Program Files"
? From a little bit of reading, it looks like the answer in some cases may be "yes", which is the only really unexpected area. – mwfearnley – 2016-06-07T11:03:05.2071Yes! See @grawity's answer here: http://superuser.com/a/373756/100787 – iglvzx – 2012-04-18T18:03:42.990
2
You should have checked all the comments ;) http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425%28v=vs.85%29.aspx
– Baarn – 2012-04-18T18:06:13.137