Custom URL Registration (Windows, Linux and MacOS)


We assume the application is located in C:\Alert.exe. You can change for your own location.

Start by opening Regedit and then create the following registry entries:

        Default) = "URL:Alert Protocol"
        URL Protocol = ""
            (Default) = "alert.exe,1"
                    (Default) = "C:\alert.exe" "%1"

This registry file reproduces this structure, you only have to import it (or adapt, if want).

You can download a test program and place it in your C:\

Download - Source Code

#include <stdio.h>

int main(int argc, char **argv) {
    int i;

    printf("%s invoked with the following parameters:\n\n", argv[0]);
    for(i=1; i < argc && argv[i] != NULL; i++)
        printf("\t[%d] %s\n", i, argv[i]);

    printf("\nPress any key to continue...");
    return 0;


To register a custom URL in Linux, you have to create a .desktop file for your application. It is achieved with entry MimeType.

We start by specifying the Exec entry. It accepts the following parameters:

Add...  Accepts...
%f      a single filename.
%F      multiple filenames.
%u      a single URL.
%U      multiple URLs.
%d      a single directory. Used in conjunction with %f to locate a file.
%D      multiple directories. Used in conjunction with %F to locate files.
%n      a single filename without a path.
%N      multiple filenames without paths.
%k      a URI or local filename of the location of the desktop file.
%v      the name of the Device entry.

So, we should pick %U for multiple URLs. Next, you can find a full example of a .desktop file:

[Desktop Entry]
Comment=Alert commandline tool
Exec=/usr/bin/Alert %U

You can download the file alert.desktop. It should be placed in the directory /usr/share/applications. Then, install the Alert application in /usr/bin (or other location of your choice):

Download - Source Code

Finally, update the cache database of MIME types handled by desktop files:

sudo update-desktop-database

Now, you can test your new settings:

xdg-open alert://test

A similar window should be shown:

enter image description here

You can also test in your browser. Only in Firefox supports it (apparently…).


You can use RCDefaultApp, which gives you a nice Preference Pane.

Download - Local Copy

In order to install the application, you have to select Open from the right menu because is not an official Mac App Store application.

enter image description here

This application is shipped with a command line tool to register customs URLs. The tool is callled lstool and is located in RCDefaultApp.prefPane/Contents/Resources/lstool.

First, you have to register the your application (we will use Mail as example):

./lstool register Mail

And then, create your custom URL:

./lstool write url alert Mail

Now, you can check your new definitions from System Preferences > Default Apps

To see if it is working, open Safari and open the URL alert://test. It should open Mail application.


The URL is not passed as argument to the application. It is necessary to make special calls the operating system to obtain it. To know more about it, you can check Handle custom URL schemes in an OS X Java application. The complete JavaDoc documentation can be found in Class Application.