views:

151

answers:

4

I'm deploying a small conversion tool on some systems, and want the users to be able to run it from the right click Open with menu. But I don't want to change the default program users have associated to this file type.

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

A: 

You can add scripts to the context menu (below Open with) by adding it in the windows registry:

  1. Open regedit
  2. Goto HKEY_CLASSES_ROOT\your_class\Shell
  3. Add a new key and give it a name
  4. Edit the (Default) value of this key and insert the text you want to show in the context menu
  5. Add a new key named Command under your newly created key
  6. Edit the (Default) value of this key and insert the command you want to execute
  7. Enjoy!
Marc
That's also what I tried before, but in my case it's not sufficient; the default association was made by hand in Explorer, and for some reason it blocks this file handling.
CharlesB
A: 

In the "File Types" Windows Dialog you can click "Advanced" on your file type and there create a custom action tied to your application.

Possibly you can also find a way to do this in a programmatic manner, or at least create a .REG file with the equivalent registry options.

ob1
Yes I want to do it programmatically
CharlesB
You can use the Win32 registry functions - http://msdn.microsoft.com/en-us/library/ms724875(VS.85).aspx - to create/change the relevant registry entries
ob1
A: 

here's a worked example for XP adding a command prompt option to folders. Create a .reg file

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\shell\Command Prompt]

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

This will make the default app, while I don't want to change the default program.
CharlesB
Not on XP it doesn't. It simply adds an option command prompt
A: 

Setting the following keys worked 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>
CharlesB