windowsbatch-fileregistryfile-association

Windows registry - register an application to open a file type


I'm making an installer for an application which has a custom URI scheme and its own file type to open with it. The application executed with a launcher.bat, In the registry I've set the launcher.bat to do so. It works as it should be, unless I want to register the application wit its name to be shown as opening application both in exporer and browsers instead of launcher.bat.

The registry file that applied by the installer script is the following (it is gets generated dynamically, so don't mind the application path as well):

Windows Registry Editor Version 5.00

; ---- Add myext extension
[-HKEY_CLASSES_ROOT\.myext]

[HKEY_CLASSES_ROOT\.myext]
"content-type"="application/myext+xml"
@="myapp"


; ---- Add myapp for protocol
[-HKEY_CLASSES_ROOT\myapp]

[HKEY_CLASSES_ROOT\myapp]
@="URL:<Application Protocol>"
"URL Protocol"=""

[HKEY_CLASSES_ROOT\myapp\DefaultIcon]
@="MyApplication.exe,1"

[HKEY_CLASSES_ROOT\myapp\shell]
@="open"

[HKEY_CLASSES_ROOT\myapp\shell\open]
@="Open with My Application"

[HKEY_CLASSES_ROOT\myapp\open\command]
@="\"C:\\Program Files (x86)\\My Application\\launcher.bat\" \"%1\""

What else should I add to the registry to do so?


Solution

  • After a few days of digging, I have found the solution:

    The registry above assigns extension to the launcher (or any executable) to open it with, but the OS only shows the executable name as the associated program - which is fine, because It wasn't registred. This could be shown on the properties window of the file which are associated to, in exprorer, when you right click on the file and choose open with, and even in browesers when a URI scheme is registed.

    To do so, the application has to be registred as well in the registry. After digging the internet, finally found on MSDN the extra registry changes that does so.

    Windows Registry Editor Version 5.00
    
    [HKEY_CLASSES_ROOT\Applications\MyApplicationLauncher.bat]
    FriendlyAppName = "My Application"
    DefaultIcon = "<MyApplicationPath>\MyApplication.exe,1"
    

    Note that using application names like launcher.bat or start.bat might cause conflicts; to prove its uniqueness, I had to rename it in the installer package to identify it.