I am using Inno Setup and am trying to associate a program that is located in the Program Files (x86)
in Windows 7. I have the following:
#define MyAppName "MyView"
#define MyAppExeName "MyView.exe"
[Setup]
AppName={#MyAppName}
[Registry]
Root: HKCR; Subkey: ".mpl"; ValueType: string; ValueName: ""; ValueData: "MyView"; Flags: uninsdeletevalue
Root: HKCR; Subkey: "MyView"; ValueType: string; ValueName: ""; ValueData: "MyView"; Flags: uninsdeletekey
Root: HKCR; Subkey: "MyView\delta.ico"; ValueType: string; ValueName: ""; ValueData: "{app}\GeoView.EXE,0"
Root: HKCR; Subkey: "MyView\shell\open\command"; ValueType: string; ValueName: ""; ValueData: """{app}\MYVIEW.EXE"" ""%1"""
Any suggestions for why the association is not working?
If you want to associate a program with an extension just add this instruction in your iss file :
In the section
^-Setup will tell Explorer to refresh its file associations information at the end of the installation, and Uninstall will do the same at the end of uninstallation.
And in the section
Explanations
Root: HKCR; Subkey: ".magi"; ValueData: "MyMAGIApplication"; ValueType: string; ValueName: ""; Flags: uninsdeletevalue
. This instruction add ".magi" key in the registry, with more accurate in HKEY_CLASSES_ROOT (HKCR). In this instruction we also haveValueName=""
so it get the default value in the registry.Root: HKCR; Subkey: "MyMAGIApplication"; ValueData: "Program MAGI"; ValueType: string; ValueName: ""; Flags: uninsdeletekey
In order to add the keyMyMAGIApplication
in HKCR with the value "Program MAGI".Root: HKCR; Subkey: "MyMAGIApplication\DefaultIcon"; ValueData: "{app}\MAGI.EXE,0"; ValueType: string; ValueName: ""
In order to associate an icon contains in the executable. "0" indicates that it's the first icon present in the executable MAGI.EXE.Root: HKCR; Subkey: "MyMAGIApplication\shell\open\command"; ValueData: """{app}\MAGI.EXE"" ""%1"""; ValueType: string; ValueName: ""
In order to add the subkey shell\open\command. With this instruction, Windows is able to launch application MAGI.EXE when an user click on a file with extension ".magi".And the result in registry :
Creating file associations has been answered on SO before. But the core documentation refers to it:
http://www.jrsoftware.org/isfaq.php#assoc
Well to summarize Windows file association There are 3 major registry settings to deal with:
-> path & icon to app
-> 'associate .magi with MyMAGICApplication (System default)
->'associate .magi with MyMAGICApplication (User default)
Regarding 1. and 2. these were covered well in previous answers. (Except the point that .magi may have been associated to let's say SomeOtherMAGICApplication before. This setting will get overwritten and is not restored on uninstall.) However to make it fully work in real 3. must also taken into account.
Okay here we got let's start with FileSample.iss:
So what to say here. Well only 1. is already done. 2.(and 3.) is done depending if the Task associate was enabled and its work is done by invoking AssocBak.cmd
Please excuse the use of batch files instead of Inno Pascal code here / feel free to implement. However as long as it is working, I keep it.
to summaries that script, its just a kind of wrapper for the assoc command adding
Okay that's it enjoy :D
This works: