This post has been imported from the old blog and has not yet been converted to the new syntax yet.
Today I experienced something weird.

Normally I run a lot of files just from 'Run' (Win+R), but today I did 'Run', 'notepad', and nothing happened...

This was weird.. As I could still open .txt files with Notepad.

I could not run notepad from 'Run'! I was amazed, I mean,.. what could break notepad? :)


First I checked if the file was still there (of course, how could I still view files otherwise..), and if my PATH variable still included Windows. Everything seemed ok.

But then I found it, it only seemed as I could not run notepad.

What happened was the following: There was a notepad.com file in the system32 dir all of the sudden (spyware, virus, don't know). And Windows decided to run that one instead of notepad.exe

So it seems Windows prefers .com over .exe when trying to run a file without an extension.

Why does this happen?

There's another environment variable, called PATHEXT, with the following data:

PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH

Now you can clearly see the order of the files. I tried the same thing with a .bat and .exe file, and changing the env var, and it worked.

I'm not sure if the .COM has to be the first in line for normal system operations?

One side-effect of this was that when I wanted to View Source of a HTML page, it would also launch the notepad.com which did nothing, and thus not showing any source! I remember a lot of people complaining about not being able to view the source of their pages, this could be what's causing it!

Hopefully I'm telling something 'new' here, that's useful ;) I never knew that order of extensions.
 
  • Leave a reply
    Items marked with * are required. (Name, Email, Comment)
    Comment is missing some required fields.
     
     
     
    To make sure you are not a computer, please type in the characters you see.