Chip Thrasher Chip Thrasher - 24 days ago 6
HTML Question

How to Open a Windows Program with JavaScript?

So I'm trying to make a projects hub for Windows (run locally with Localhost) that will open different apps (e.g. a CAD program) at the click of a button. Is this insecure? If not, how would I do it? If so, is there an alternative? Thanks!

Answer

A URI (Uniform Resource Identifier) will provide for the best user experience. A URI is a schema that can launch an application as well as pass data into the application. The most common example of a URI is the mailto: for launching a computer's mail client from a website.

Creating a URI involves editing the registry. Here is some Microsoft Documentation on how to do it. Looking at other examples in the registry like mailto: https://msdn.microsoft.com/en-us/library/aa767914(v=vs.85).aspx

Lastly, I have seen people use <a href="path.lnk"> to shortcut links that works ok in Internet Explorer. You will still get a prompt to open or save; however, its the simplest solution.