C:\Program

Posted by: drakino

C:\Program - 12/01/2012 17:49

Came across an odd one with Windows today (ugh, already hitting "fun" issues again with this OS), and I can't find a good reason why this is an issue.

An unquoted path caused a script to create a file called Program in the C:\ drive. When this occurred, and Windows 7 rebooted, it warned about this and recommended renaming the file. When I didn't, I noticed a 3rd party service wasn't running. Attempting to start it lead to Error 193:0xc1 (Not a valid Win32 application).

My first though is that it's due to the legacy 8.3 filenames, and C:\Program clashing with Program Files (Progra~1 normally in 8.3 format). But that doesn't fully make sense to me, since program is just 7 characters, and shouldn't have resulted in a ~1,~2 situation.

Any ideas why C:\Program can tank some programs?
Posted by: wfaulk

Re: C:\Program - 12/01/2012 19:41

"dir /x" will show you the 8.3 names. Maybe that will provide some information?
Posted by: wfaulk

Re: C:\Program - 12/01/2012 19:42

Also:

C:\Program Run
Run, Program, Run
Posted by: drakino

Re: C:\Program - 12/01/2012 20:51

dir /x confirms that it is just C:\Program with no special second 8.3 name. Only ones on the C:\ that did have special 8.3 names are PROGRA~1 Program Files and PROGRA~2 Program Files (x86)
Posted by: tfabris

Re: C:\Program - 12/01/2012 21:37

Originally Posted By: drakino
Any ideas why C:\Program can tank some programs?


Question: Was it only the third party service that failed? i.e., not Windows itself?
Posted by: peter

Re: C:\Program - 12/01/2012 21:59

Originally Posted By: drakino
it warned about this and recommended renaming the file

That's very suspicious. What exactly did the warning say? Perhaps there's some special and terrible hack in there somewhere that says, if you try and execute a command called "C:\Program", and that file doesn't exist, and the command's first argument starts with "Files\", then magically treat the command and first argument as if they were a single command with a space in the middle. That would be foul and nasty, but it would provide a modicum of compatibility with buggy legacy programs, and Microsoft have a history of resolving that sort of dilemma in favour of foulness and nastiness.

Peter
Posted by: drakino

Re: C:\Program - 12/01/2012 22:27

Windows booted fine, and I think all my normal services started fine. It was just one 3rd party service that had a fit. Searching for the full error in Google turns up people hitting this on older Windows versions, with Windows specific services also being impacted by whatever weirdness is going on. I guess Microsoft fixed all of their instances where it could break things, but not every 3rd party. Seeing references to a lot of different apps breaking due to this.

Here is the exact dialog that pops up.
Originally Posted By: File Name Warning
There is a file or folder on your computer called "C:\Program" which could cause certain applications to not function correctly. Renaming it to "C:\Program1" would solve this problem. Would you like to rename it now?

It also has a checkbox with an option "Don't perform this check at startup" along with buttons to rename the file or ignore it.

I think Peter's explanation is probably true. Some old API likely allowed paths with spaces, and didn't quote the path. Makes me wonder if there was something similar for the older "Documents and Settings" folder.

I should probably stop wondering why MS stuff works like it does, before I suffer some sort of elder god style madness.
Posted by: wfaulk

Re: C:\Program - 13/01/2012 15:15

Haha. I love it.

If corporations are people (my friend), then Microsoft is an Old One.
Posted by: Roger

Re: C:\Program - 13/01/2012 15:27

Originally Posted By: peter
Perhaps there's some special and terrible hack in there somewhere that says, if you try and execute a command called "C:\Program", and that file doesn't exist, and the command's first argument starts with "Files\"


Not quite. Watch it with Process Monitor.

Given "C:\Program Files\Foo\Bar.exe", it tries:

"C:\Program" "Files\Foo\Bar.exe"

That fails, so it tries the next one, which works. There's nothing special about "Files\", or "C:\Program", for that matter.

I'm not sure what it does for "C:\Program Files\Foo\Bar.exe baz quux"...