Click here to Skip to main content
Click here to Skip to main content

Running a ClickOnce Application from Another Program

, 29 Apr 2008 CPOL
Rate this:
Please Sign up or sign in to vote.
A bootstrap loader to execute a ClickOnce application - written in C#


There are times when it is desirable to run a ClickOnce application from another program. While there are several articles that address this to some degree, I have not found any which seem adequate.

Some caveats: I'm only concerned with offline-capable ClickOnce applications. Also, this code doesn't help you get a return code from a ClickOnce application. Moreover, this technique will only work if there is a single instance of the ClickOnce application running at any time.


A good read in this area is "Smart Client Deployment with ClickOnce" by Brian Noyes.

Using the Code

So, why bother? Well, imagine (if you will) a third party application with a scripting language which includes the ability to execute a program. Further, imagine that you have multiple people (Windows users) using that application. How can you create a single script which will have the application execute a ClickOnce application?

A ClickOnce application will have a different location depending on the current user, so you need something which will do that redirection. My solution is to use the application described herein, ExecuteClickOnceApp, which will execute a ClickOnce application given the company name and the application name. Note that this bootstrap application is distributed via a setup project. I can't use ClickOnce for the bootstrap program, but it is a mostly static program launcher, and allows the less generic and more changeable applications to be run as ClickOnce applications.

Back to the script – if for example, my company name is FHCRC, and my application is called BuildIDWorklist, then I will script in the command:

ExecuteClickOnceApp FHCRC\BuildIDWorklist <arguments >

ExecuteClickOnceApp will build a command line to the shortcut, along the lines of:

<USERPROFILE>\Start Menu\Programs\FHCRC\BuildIDWorklist.appref-ms

It will then start up a process with this command line and wait for the process to exit. That’s all folks!

Points of Interest

There were a couple of maddening things about this development process. First, when using Process.Start() to initiate a ClickOnce application, using an application reference (as above), the returned process is not valid. So, you can't wait for it to complete, or check for a return code. Instead, you have to examine all running processes looking for your application.

The other big gotcha is that there does not appear to be a straightforward way to get at the exit code from the ClickOnce application. Even after you locate the process, the Framework refuses to divulge the exit code on the grounds that you didn't actually start the process in question.


  • 29-04-2008: Initial upload


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Web Developer
United States United States
No Biography provided

Comments and Discussions

GeneralMy vote of 5 PinmemberGaby Mora G3-May-13 15:35 
GeneralMy vote of 1 PinmemberAlex Cherkasov26-Sep-12 16:12 
GeneralMy vote of 2 Pinmemberido.ran3-Mar-12 11:21 
GeneralMy vote of 4 Pinmembercrystalmac3-Mar-12 5:49 
GeneralShellExecute [modified] PinmemberDizZ22-Mar-10 5:42 
GeneralStart the .application click once file PinmemberAdam Stechschulte19-Feb-10 6:13 
GeneralAwesome! Pinmembermd5sum11-Feb-10 10:57 
GeneralURI formats are not supported [modified] PinmemberMember 446494210-Aug-09 13:50 
GeneralRe: URI formats are not supported PinmemberJosé Luis Márquez10-Aug-09 14:12 
GeneralLanguage PinmemberMember 446494210-Aug-09 6:57 
GeneralRe: Language Pinmembersandal_tolk27-Aug-09 21:55 
AnswerRe: Language Pinmemberpolleke_Gent28-Oct-09 1:06 
GeneralRe: Language PinmemberDizZ22-Mar-10 5:50 
GeneralCan't have Arguments Pinmemberdbrenth6-May-08 9:06 
GeneralRe: Can't have Arguments Pinmemberdwrogers6-May-08 20:26 
AnswerRe: Can't have Arguments [modified] PinmemberBabba7216-Jul-09 22:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.1411023.1 | Last Updated 29 Apr 2008
Article Copyright 2008 by dwrogers
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid