Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I changed the association to use upon launching a .py file, via Windows Explorer:

  1. Tools -> Folders -> File types.
  2. Then browse to .py.
  3. Change the association to Wordpad.

Now when I type the name of a py file in the command line, Wordpad opens it.

But assoc and ftype in the command line still return the following:

C:\> assoc .py
.py = Python.File

C:\> ftype Python.File
Python.File = "C:\Program\Python27\python.exe" "%1" %*

How come the association is working, but assoc and ftype are not aware of it?

I did restart the prompt.

More info from my registry:

= Python.File

= wordpad.exe


= Python.File

More registry:

= "C:\Program\Python27\python.exe" "%1" %*`

I suppose this is what is showing up in ftype Python.File. But it does not seem to get used.

(I am doing this for testing, so I can eventually choose my default version of Python easily).

share|improve this question

4 Answers 4

Depending on how you call a file will depend on what verb is used. The verb you use determines what Windows will do with it. The standard verbs are Open, Edit, Print, Play, and Preview. However, it is possible to create your own verbs. The most commonly added verb is the Open With family (including OpenWithProgIDs), which add that little context sub-menu under "Open With" to give you possible alternatives. If you install Paint.NET, for example, and then right-click a .jpg file, you'll see the Open With entry expands to a submenu that lists Paint.NET, Paint, and whatever Microsoft called the picture viewer for your version of Windows.

Additionally, what Unsigned Code Labs said is very important. When you're debugging classes, you need to look at HKLM\Software\Classes\ and HKCU\Software\Classes. HKCR is very useful for querying the system, but not so good for finding out why it's misbehaving.

I did a little testing on my Windows 7 system with procmon.exe, and the assoc and ftype commands appear to try to write directly to HKCR, and the system apparently interprets that as writing to HKLM. My current account is a member of the admin group, but UAC is enabled. I got access denied when I tried assoc .mytest=MyTest.File.

Oddly, if I create an association by right-clicking a file called test.mytest and associating it with Notepad, neither assoc nor ftype sees this association. The association is definitely there in HKCU and HKCR. I haven't tried rebooting, however.

share|improve this answer

i don't know how can you make the match between registry and what appears in ftype and assoc. To me and as i see to you as well the ftype and assoc command are useless. What i do to change the default program for a given extension in a programatic way(vs the standard and more simple way using explorer) is modify this registry key


For example, if i want to open my mp3s with mplayer i put in


the value of "mplayerc.mp3"

What are the complication of doing this: first you need to know valids ProgIDs(use ftype), and second you need write access to that hive. Windows automatically put a deny ACL for the UserChoice key, so you need to find a way to remove that deny rule in order to get the write access. I use the program subinacl, that you could download from here http://www.microsoft.com/downloads/en/details.aspx?FamilyID=e8ba3e56-d8fe-4a91-93cf-ed6985e3927b&displaylang=en to modify the permissions. Also you could use the 3rd party program SetACL. I recomend the first because the syntax is a lot more simple.

share|improve this answer

Explorer (the Windows shell) always gives preference to the application specified in the vendor key which is specified under the extension's default value. (In your case .py is the extension, Python.File is the vendor key.)

ftype and assoc may read their values from other areas, I do not know for sure. Thats just how Explorer does it.

EDIT: This page may be of interest to you: MSDN - File Types

Especially this:

The HKEY_CLASSES_ROOT subtree is a view formed by merging HKEY_CURRENT_USER\Software\Classes and HKEY_LOCAL_MACHINE\Software\Classes.

Perhaps this is where the different parts of Windows clash, if there is a "default" association in HKEY_LOCAL_MACHINE, that is getting overridden by the one you defined on your account (which would then be stored in HKEY_CURRENT_USER).

share|improve this answer

The confusion here is between what is used to open a file and what is used to run a file. The registry key


is what tells windows how to open the file. Double clicking on the file will open the file with this application.

As the file isn't an executable file, the command line assumes that you want to open the file with the default application, as if you had double clicked it.

Changing the association back to C:\Program\Python27\python.exe or editing the registry key to point to python should return it to how it used to be, where windows assumes you want to open the file with the default program, which is python.exe, which then runs the program.

share|improve this answer
If I understand correctly, the key .py\Application is used to open the py files. What I do not understand is in what cases the value in Python.File is used. –  Gauthier Mar 2 '11 at 12:40
According to Majenko it depends on weather given extension is treated by Windows like executable (see PATHEXT variable). However I recall reading in the past that associates made from within Explorer always overwrite those from Classes registry key. –  Piotr Dobrogost Oct 28 '12 at 15:18

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.