7

In CMD I get this:

C:\>assoc .css
.css=CSSfile

C:\>ftype CSSfile
File type 'CSSfile' not found or no open command associated with it.

But in explorer, CSS files have icon and I can double click and notepad is used to open it. Why does my Windows open CSS file with notepad?

I'm not asking HOW to open a file with certain program. I'm asking WHY .css file is associated with notepad, given "File type 'CSSfile' not found or no open command associated with it" ftype command tells.

2
  • 2
    ...because Windows is dumb? May 19, 2016 at 0:06
  • install visual studio and see what happens. This is a joke... VS takes forever to start and it's the default for a lot of file types (xml).
    – MattSizzle
    May 19, 2016 at 2:52

1 Answer 1

7

Why does my Windows open CSS file with notepad?

Right click on the CSS file and click "Open With" > "Choose default program..."

You will see the the default program is set to "Notepad":

enter image description here

You can use this dialog to change the default application if you wish to do so.

In the registry the key HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.css has value PerceivedType set to text:

enter image description here

Warning:

  • Do not modify this entry. It is mentioned only to explain why Notepad is the default program.

Notepad is the default application for opening text files.

You can open the css file in a cmd shell by typing it's name and it will also open in notepad:

enter image description here


Why Notepad is the default application for opening text files?

If I have VIM, how do I make VIM the default application for extensions whose PerceivedType is text?

Notepad is registered as the command to be executed for files of perceived type text.

To change the command to vim edit the registry values described below and replace %SystemRoot%\system32\NOTEPAD.EXE with the path to vim.exe.

Registering a Perceived Type

Registry values for perceived types are defined as subkeys of the HKEY_CLASSES_ROOT\SystemFileAssociations registry subkey.

For example, the perceived type text is registered as follows:

HKEY_CLASSES_ROOT
   SystemFileAssociations
      text
         shell
            edit
               command
                  (Default) = "%SystemRoot%\system32\NOTEPAD.EXE" "%1"
            open
               command
                  (Default) = "%SystemRoot%\system32\NOTEPAD.EXE" "%1"

A file type's perceived type is indicated by including a PerceivedType value in the file type's subkey. The PerceivedType value is set to the name of the perceived type registered under HKEY_CLASSES_ROOT\SystemFileAssociations registry subkey, as shown in the previous registry example.

To declare .cpp files as being of perceived type "text", for example, add the following registry entry:

HKEY_CLASSES_ROOT
   .cpp
      PerceivedType = text

Source Application Registration

15
  • He wants to open with command line. And he can literally just right click to change the default program instead of manually changing the registry?
    – rassa45
    May 18, 2016 at 20:00
  • @ytpillai You can open from the command line. Read the answer carefully.
    – DavidPostill
    May 18, 2016 at 20:01
  • @ytpillai Yes, you can change the default program (if you so wish) by right-clicking.
    – DavidPostill
    May 18, 2016 at 20:02
  • Apologies I did not read carefully. Your answer is an interesting one where he does not need to write anything else. But why did you discredit mine? Doesn't my answer essentially do the same thing except with two more words? I don't want to discredit yours, only understand why I am wrong
    – rassa45
    May 18, 2016 at 20:03
  • 1
    @LoveRight I'm in a good mood so I will answer your new question. See the updated answer.
    – DavidPostill
    May 18, 2016 at 21:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .