aleksandr.shtifanov
Posts: 20
Joined: Mon Jun 02, 2014 8:31 am

Conditionally set file association

I want to create a file association that recognizes whether an association for a custom file extension has already been set or not.

How do I achieve this task?
Eusebiu
Posts: 4931
Joined: Wed Nov 14, 2012 2:04 pm

Re: Conditionally set file association

Hi,

In order to see if a file association was already set for an extension, you can create a search for the appropriate registry key located in the "HKEY_CLASSES_ROOT" hive. Based on that search, you can set a condition for the component related to the file associations defined in your project.

Let me know if this helped, otherwise give me more details about your scenario.

Best regards,
Eusebiu
Eusebiu Aria - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
aleksandr.shtifanov
Posts: 20
Joined: Mon Jun 02, 2014 8:31 am

Re: Conditionally set file association

Thanks for your response.

I have tried this approach but I don't know how to validate the "search property" within the condition editor.
There is the possibility to check for an existing registry key with the search which I did, but the condition editior always returns TRUE when prevalidating. There must be something wrong with my approach.

Also, how do I properly check for the association? Or how/where do you set the association in the registry?
I found a .myextension key with a value of "myextension_auto_file" .
There also is a key "HKEY_CLASSES_ROOT\Applications\MyApp.exe\shell\open\command" with a value of "C:\Projects\MyApp\bin\MyApp.exe" "%1".

The association is still set, after I manually removed the keys so I am not sure if these are the right entries to check.
Eusebiu
Posts: 4931
Joined: Wed Nov 14, 2012 2:04 pm

Re: Conditionally set file association

Hi,
I have tried this approach but I don't know how to validate the "search property" within the condition editor.
If you want to verify if a search finds any value on your machine or not, you can use the "Test Search" toolbar button.
There is the possibility to check for an existing registry key with the search which I did, but the condition editior always returns TRUE when prevalidating. There must be something wrong with my approach.
The "Validate" button from the "Edit Condition" dialog only tells if that condition is spelled correctly, it does not tell if it is True or False.
Also, how do I properly check for the association? Or how/where do you set the association in the registry?
I found a .myextension key with a value of "myextension_auto_file" .
There also is a key "HKEY_CLASSES_ROOT\Applications\MyApp.exe\shell\open\command" with a value of "C:\Projects\MyApp\bin\MyApp.exe" "%1".
The association for an extension is set in the registry under the "HKEY_CLASSES_ROOT" key. You can study about this in the "File Types and File Associations" articles.

You can also find a brief explanation in the "Script to associate an extension to a program" thread.

Best regards,
Eusebiu
Eusebiu Aria - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”