How to associate a file extension with a program without making it the default program

I am deploying a small conversion tool on some systems and want users to be able to run it from the Open with context menu. But I do not want to change the default program associated with this file type.

It is easy to associate a file extension / type with a program, but how to do it (programmatically, of course) without changing the default program?

+7
windows file-association
source share
5 answers

By setting the following keys for me:

 key HKLM/SOFTWARE/Microsoft/Windows/CurrentVersion/App Paths/<progname>: "" = <appPath> key HKCR/Applications/<progname>/SupportedTypes: <fileExt> = "" key HKCR/<fileExt>: "" = <progID> key HKCR/<progID>/OpenWithList/<progName> key HKCR/<fileExt>/OpenWithList/<progName> key HKCR/SystemFileAssociations/<fileExt>/OpenWithList/<progName> delete key and subkey at HKCU/SOFTWARE/Microsoft/Windows/CurrentVersion/Explorer/fileExts/<fileExt> 
+4
source share

You can add scripts to the context menu (under Open with) by adding it to the Windows registry:

  • Open regedit
  • Go to HKEY_CLASSES_ROOT\your_class\Shell
  • Add a new key and give it a name
  • Edit the (Default) value of this key and paste the text that you want to display in the context menu
  • Add a new key named Command under the newly created key
  • Edit the (Default) value of this key and paste the command you want to execute
  • Enjoy it!
+1
source share

In the Windows File Types dialog box, you can click Advanced on your file type and create a custom action that is tied to your application.

Perhaps you can also find a way to do this programmatically, or at least create a .REG file with equivalent registry settings.

0
source share

I got the correct FILE ASSOCIATION using these cmd commands. (just an example):

 REG ADD "HKEY_CLASSES_ROOT\Applications\notepad++.exe\shell\open\command" /v @ /t REG_SZ /d "\"C:\\Program Files\\Noteepad++\\notepad++.exe\" \"%1\"" /f REG ADD "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.txt" /v "Application" /t REG_SZ /d "notepad++.exe" /f REG ADD "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.txt\OpenWithList" /v "g" /t REG_SZ /d "notepad++.exe" /f assoc .txt=MyCustomType ftype MyCustomType="C:\Program Files\Noteepad++\notepad++.exe" "%1" 

(better to put them in a .bat file)

0
source share

here is a processed example for XP adding a command line parameter to folders. Create a .reg file

Windows Registry Editor version 5.00

[HKEY_CLASSES_ROOT \ Directory \ shell \ Command Line]

[HKEY_CLASSES_ROOT \ Directory \ shell \ Command Prompt \ Command] @ = "cmd.exe / k cd \"% 1 \ ""

-2
source share

All Articles