1

This is for Windows.

I have a flash application I am converting to AIR. I built a captive installer using NSIS and it works fine. However I would like to have an icon on a website which checks if the application is already installed and ask the user if they wish to run it. If it is not installed, they get the option to download it.

I am fairly certain this is doable, because Zoom and GoToMeeting both do this.

My searching skills seem to be failing me when looking for this.

Edit:

It appears the best/only way to do this is to create a custom protocol for the application. Something like DoDaApp://.

Which brings up the next set of questions;

  1. How to create an NSIS file which will create the appropriate registry entries on the client computer? As a user, not admin.
  2. How to check if the protocol is currently installed on the computer?
Paul Stearns
  • 856
  • 9
  • 30
  • Does this answer your question? [How to detect browser's protocol handlers?](https://stackoverflow.com/questions/836777/how-to-detect-browsers-protocol-handlers) – Raymond Chen Jun 30 '20 at 13:36
  • It shines a light in the direction I need to go, which is to create a custom protocol for the application. See my edit to the original question. – Paul Stearns Jun 30 '20 at 15:05

2 Answers2

1

This is a partial answer as it does not work in Edge. I'll explain the issue below.

As recommended in How to detect browser's protocol handlers you can use timeout & blur event handlers. Here is my interpretation of the code;

function checkCustomProtocol(inProtocol,inInstalLink,inTimeOut)
{
    var timeout = inTimeOut;
    window.addEventListener('blur',function(e)
        {
            window.clearTimeout(timeout);
        }
    )
    timeout = window.setTimeout(function() 
            {
              console.log('timeout');
              window.location = inInstalLink;
            }, inTimeOut
        );

    window.location = inProtocol;
}

Microsoft Edge is ever so helpful by popping up a dialog box telling you "You'll Need a new app to open this" which "blurs" the screen, not allowing download of the file.

So I will be posting another question on how to make it work in Edge. I have reviewed ismailhabib's code but the known issues section says it doesn't work with Edge either.

Paul Stearns
  • 856
  • 9
  • 30
1

Here is a more complete answer. It has been lightly tested in IE 11, Microsoft Edge, Chrome and Firefox. I also added comments;

/*
    checkCustomProtocol - check if custom protocol exists
    inProtocol - URL of application to run eg: MyApp://
    inInstallLink - URL to run when the protocol does not exist.
    inTimeOut - time in miliseconds to wait for application to Launch.
*/
function checkCustomProtocol(inProtocol,inInstalLink,inTimeOut)
{
    // Check if Microsoft Edge
    if (navigator.msLaunchUri)
    {
        navigator.msLaunchUri(inProtocol, function () 
            {
                //It launched, nothing to do
            },
        function()
            {
                window.location = inInstalLink; //Launch alternative, typically app download.
            }
        );
    }
    else
    {
        // Not Edge
        var timeout = inTimeOut;
        //Set up a listener to see if it navigates away from the page.
        // If so we assume the papplication launched
        window.addEventListener('blur',function(e)
            {
                window.clearTimeout(timeout);
            }
        )
        //Set a timeout so that if the application does not launch within the timeout we 
        // assume the protocol does not exist
        timeout = window.setTimeout(function() 
                {
                  console.log('timeout');
                  window.location = inInstalLink; //Try to launch application
                }, inTimeOut
            );

        window.location = inProtocol; //Launch alternative, typically app download.
    }
}
Paul Stearns
  • 856
  • 9
  • 30