2

i want to pen application installed in desktop through web application i am using this code. but only supported in IE.i want to open it in firefox or Chrome

<html>
    <head>
        <title>Application Executer</title>
        <HTA:APPLICATION ID="oMyApp" APPLICATIONNAME="Application Executer" BORDER="no" CAPTION="no" SHOWINTASKBAR="yes" SINGLEINSTANCE="yes" SYSMENU="yes" SCROLL="no" WINDOWSTATE="normal">
        <script type="text/javascript" language="javascript">
            function RunFile()
            {

                WshShell = new ActiveXObject("WScript.Shell");
                //call file
                WshShell.Run("C:/MathType.exe", 1, false);
            }
        </script>
    </head>
    <body>
        <input type="button" value="Run Notepad" onclick="RunFile();"/>
    </body>
</html>
nikhil
  • 33
  • 4

2 Answers2

1

You can't do that from Chrome or Firefox due to sandbox that prohibits use of local resources.

The only solution I've found is to build an extension in Mozilla Firefox which can launch your app. Extensions live outside the sandbox so they can execute local resources. See this page for how to do that. You may be able to do it cross-browser using crossrider, though I haven't had success with that yet.

You could alternatively build a thick client populated from a web service, and launched from the browser through an extension as mentioned above. This is what I'm doing to get around the sandbox. I'm using local XUL for this.

Source: Similar question "how to start up a desktop application in client side "

  • 1
    XUL is deprecated and XUL-based add-ons will only work with Firefox <57. They've been replaced with WebExtensions, which have less possibilities than XUL-based add-ons. – Felix Jan 31 '18 at 12:48
1

You can't, at least not directly. And for a good reason. If web pages could run arbitrary local applications, they could also delete, modify or read your local files.

The other answer mentions a Firefox extension. However, this only works for Firefox up to version 56. Firefox 57 and newer use WebExtensions which are limited in regards to local system access.

You could create a WebExtension that uses Native Messaging and provides an API to the web page. You'd have to install a proper native endpoint for the local application. This native endpoint cannot be installed along the WebExtension.

Your communication would look somewhat like this:

Web page <-1-> WebExtension <-2-> Native Messaging Host <-> Local Application 1: postMessage()/onMessage 2: Native Messaging

Felix
  • 129
  • 9