CMD redirects PY code to new window that disappears

CMD’s assoc and ftype commands are outdated. They were introduced back in Windows NT 4.0 (1996) and haven’t been significantly updated since then. They only show and modify the system software classes in “HKLM\Software\Classes”, for a given file type (e.g. “.py”) or given programmatic identifier (e.g. “Python.File”). A lot has changed since 1996. File associations can be defined in many places in the registry:

  • HKCU\Software\Classes
  • [HKCU|HKLM]\Software\Classes\Applications
  • [HKCU|HKLM]\Software\Classes\SystemFileAssociations
  • [HKCU|HKLM]\Software\RegisteredApplications – “Capabilities” key paths
  • [HKCU|HKLM]\Software\*\Capabilities\FileAssociations

More importantly, the shell API’s calculated associations and user choices are found in “HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts”.

If you have admin access, using ftype to set a file association to a given progid at the system level may work sometimes, since the shell will recompute the file association, and the new file association might take precedence. But that’s not necessarily the case, and certainly it’s not the case if the user has locked in some other preferred application (e.g. “always use this app to open …”).

If the py launcher is effectively associated with “.py” files, then in the settings for “Apps -> Default apps”, the “.py” file type will be associated with a “Python” app that has a rocket on its icon. If it’s not, click to modify it. If the dialog to select another app doesn’t include a “Python” app with a rocket on its icon, then something is configured incorrectly.

2 Likes