How to Open a Windows Program with JavaScript?

15,676

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.

Share:
15,676
Chip Thrasher
Author by

Chip Thrasher

Web developer &amp; graphic designer.

Updated on June 11, 2022

Comments

  • Chip Thrasher
    Chip Thrasher almost 2 years

    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!

  • ThomasRones
    ThomasRones over 5 years
    I'm new to javascript so to execute I'm using window.open(uri); Is there a better way?
  • gigaduck
    gigaduck over 5 years
    You can use window.open(uri).... but on the client side( i.e. the customer's computer), there needs to be something in the computer's 'registry'. For security reasons, a general computer will not allow you to launch a program. In a corporate environment, one can have the registry updated in order to allow for proper launching of applications.