Open executable application on client using URL or Link

Sometimes you need a solution to open an application on client machine when user clicks on a link. It’s a common scenario in some cases.

For example, you probably have seen mailto: url scheme. When you click on such links, the default mail application will open to send an email. Or as another example you can see such feature in SharePoint applications which opens OneDrive for Business for synchronizing documents or use other office applications. Also skype: is another example.

Also you probably have seen Report Builder application in SSRS. When you click on report builder link in SSRS, at the first time, the report builder application will be installed on your client and the next time which you click on that link, the application opens on your client.

To have such feature in your application you can use either of the following options:

  1. You can register an application to a custom URI Scheme, then you can activate that application by the specified URL and pass parameters in URL. For more information take a look at: Registering an Application to a URI Scheme.

  2. You can use a ClickOnce deployment by specifying an installation URL. Then you can simply open the application using that URL and pass parameters to the application using query string.
    For more information take a look at: How to: Specify the Location Where End Users Will Install FromHow to: Retrieve Query String Information in an Online ClickOnce Application

Important Notice

Be careful! You may introduce security holes to your application and clients. When passing data you should be careful about security vulnerabilities like Injection, Insecure Direct Object References, SensitiveData Exposure, and so on.

Usually you should only expose a minimal secure set of features of the program using url and pend the operations to users confirmation. For example mailto: activates the mail program with some minimal data but doesn’t send email. The users should press send themselves.

Example

I’ve created an example that demonstrate the feature. It handles myapp: url scheme and shows a message box containing the values that is passed though url to the application.

The sample contains 2 projects:

  • A Windows Forms Application that will be installed and will run when a link of “myapp:” protocole is clicked.
  • A Visual Studio Setup Project which installs the application and also setup registery settings to let the windows application handle “myapp:” protocole.

Download

You can download the code here:

You May Also Like

About the Author: Reza Aghaei

I’ve been a .NET developer since 2004. During these years, as a developer, technical lead and architect, I’ve helped organizations and development teams in design and development of different kind of applications including LOB applications, Web and Windows application frameworks and RAD tools. As a teacher and mentor, I’ve trained tens of developers in C#, ASP.NET MVC and Windows Forms. As an interviewer I’ve helped organizations to assess and hire tens of qualified developers. I really enjoy learning new things, problem solving, knowledge sharing and helping other developers. I'm usually active in .NET related tags in stackoverflow to answer community questions. I also share technical blog posts in my blog as well as sharing sample codes in GitHub.

Leave a Reply

Your email address will not be published. Required fields are marked *