Changing file associations from command line
on NT (4, 2k, xp) there are two commands built into cmd.exe used display and alter file associations.
ASSOC
- to change file extension associations.
FTYPE
- to display or modify file types used in file extension associations.
I don’t know how well these work or how complete their changes are. use the /? switch for more help.
See also EmacsClient.
Changing File Types in Windows Explorer
Instead of the above or editing the registry keys directly you can in Windows Explorer from the menus choose
Tools - Folder Options
and then the tab “File Types”.
Make files with no extension be treated as text files
In the Command Prompt execute:
ASSOC .=txtfile
If that doesn’t work, then investigate the following registry keys. Possibly delete them and repeat the above step.
HKEY_CLASSES_ROOT\.
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.Open text files with EMACS
In the Command Prompt execute, after adapting the path of EmacsClient:
FTYPE txtfile="C:\Program Files\Emacs\bin\emacsclientw.exe" -n "%1"
Other ramblings
- There are many ways and places the verbs are stored. HKEY_CLASSES_ROOT contains many of them (using various rules), but a few of the other places they may be found (according to my rummaging around) are:
- [HKCU|HKLM]\Classes\Applications
- [HKCU|HKLM]\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts
- [HKCU|HKLM]\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\Folder
- [HKCU|HKLM]\Software\Microsoft\Windows\CurrentVersion\Explorer\AppKey
- [HKCU|HKLM]\Software\Microsoft\Windows\CurrentVersion\Explorer\Associations
- [HKCU|HKLM]\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\ContentTypeHandlers
- … it appears almost everything under ::[HKCU|HKLM]\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer may be playing a role...
- [HKCU|HKLM]\Software\Microsoft\Windows\CurrentVersion\Extensions
- [HKCU|HKLM]\Software\Microsoft\Windows NT\CurrentVersion\Extensions
- they also may appear in .ini files (though not likely)
- Not all of the the right-click entries are 'verbs'. I think they are called ShellExtensions, and might (i'm probably wrong) be accessible by using IContextMenu()::QueryContextMenu(), IContextMenu()::GetCommandString(), and IContextMenu()::InvokeCommand() [through some COM goo (which i don't understand)].
CategoryWThirtyTwo