How do I add a Windows file type association using InstallShield?
Asked Answered
K

2

6

I wrote an application to accept a filepath (file with custom extension) as an argument and then do some processing on it.

The idea being that I could associate (using windows functionality) the custom file with my executable app that I install (via install shield installer).

I would like to be able to double-click my file with the custom extension and have it passed to my executable for processing.

However, the behaviour I get is this:

  • if I double click my file (with the custom extension) it does nothing.
  • if I drag and drop the file on to my executable program then it works as expected.

So is it possible to get this to work by simply double-clicking my custom file?

I guess windows is attempting to open the custom file using the executable which maybe is not the same as passing it in as an argument?!

Any help appreciated.

thanks, KS

Knorr answered 8/4, 2013 at 15:39 Comment(2)
What installation technology are you using (MSI or InstallScript) and what have you tried to associate the extension with your program? You may just be missing a "%1", but your description is insufficient for me to tell.Devine
Hi, I right-clicked the file and associated it with my executable.Knorr
M
6

Using InstallShield 2013:

For A Custom File Type

  1. Switch to the "Installation Designer" tab.
  2. In the frame on the left, expand "Organization" and select "Components".
  3. From the list of Components, expand options for your primary exe, then expand "Advanced Settings" and select "File Types".
  4. Right click "Extensions" and select "New Extension". Enter the extension WITHOUT a leading period.
  5. Your extension should have had the "verb" "Open" automatically added for it when you created it. Select that. Enter a "Display Name" e.g. "&Open with MyApp". Enter an "Argument" e.g. "%1" (that passes the file name to the exe wrapped in quotes to handle long filenames/spaces.)
  6. Select your new extension from the list, then type in a "ProgID" for it. For example, "MyApp.Document".

To define a specific icon to associate with the type (rather than the implicit exe icon):

  1. Click on the "ProgID" you added ("MyApp.Document" or whatever). Click in the "Icon" field, then click the "..." button which appears. That will allow you to browse to an icon file.

For A "Common" File Type

If a file type doesn't "belong" to your application exclusively, you may want to add your application to the list of choices for opening that type, but without making it the default program, or changing the default icon. Here's how to achieve that...

  1. Switch to the "Installation Designer" tab and follow the instructions for a Custom File Type.
  2. In the frame on the left, expand "Organization" and select "Components".
  3. From the list of Components, expand options for your primary exe, then select "Registry Data".
  4. In the "Destination Computer Frame", right-click on "HKEY_CLASSES_ROOT" and select "New"..."Key". Name the key the file extension (INCLUDING the leading peroid) for which you are defining the association.
  5. Right-click on that new key and select "New"..."Default Value". Then, right click on that default value, select "Modify". Enter the ProgID for the what should be the default application to open this type and dicate the icon. You may need to check the registry to determine this value. For example, the standard default for a zip file is "CompressedFolder". Figuring this out is the most tricky part to this procedure.
  6. Right-click on that new key and select "New"..."Key" again to create a sub key. Name the sub key "OpenWithProgids".
  7. Right-click on the "OpenWithProgids" key and select "New"..."String Value". Name that value the ProgId you defined to be the default. Leave this value "empty" (the "name" is the "value").
  8. Right-click on the "OpenWithProgids" key and select "New"..."String Value" again. This time, name the value the ProgId you defined for your application when you followed the instructions for a Custom File Type.
Moores answered 4/4, 2016 at 15:53 Comment(0)
A
4

Whatever your installation method is (installscript, MSI, etc) you basically need to create a few HKEY_CLASSES_ROOT entries. Depending on your method, there are different ways to go about it (for example in an MSI installer created by installshield if you follow the guidelines it can also trigger an installation repair for your application if it detects there are problems.

The root you need though: (we'll pretend your extension is .xyz)

  1. Under HKCR create a new key named ".xyz" (you can see many others here for example
  2. In the default value, set the data to some name that means something like "myapp.xyz"
  3. Create a new HKCR key named "myapp.xyz" to match what you created in 2
  4. In the default value, set the data to a descriptive label. For example "My App Data File"
  5. Create a subkey called shell (you can set the default value here to "open", which will then make open the default action in explorer)
  6. Create a subkey called open
  7. Create a subkey called command
  8. In the default value of the command key set the value to be "c:\path\to\installfolder\appname.exe" "%1" (note all quotes in this instance matter)
  9. You can also create a subkey under "myapp.xyz" called DefaultIcon, which points to an icon file that will be associated with your extension in explorer.

If you use installshield, a lot of the above is done for you; though I've had to tweak it in the past to make it match the desired output in more complex applications with multiple file formats.

Ambroid answered 9/4, 2013 at 16:13 Comment(3)
Ok, now that everything in the registry is set, I receive the following error when double-clicking my file: "The parameter is incorrect." Any suggestions?Knorr
It kind of works now :P Except I get this jip about the app not being in the Remote Apps list. Looking into it....Knorr
Are you doing this remote? technet.microsoft.com/en-us/library/cc753610.aspxAmbroid

© 2022 - 2024 — McMap. All rights reserved.