Click here to Skip to main content
12,820,914 members (31,593 online)
Click here to Skip to main content
Add your own
alternative version


24 bookmarked
Posted 29 Apr 2008

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

You may also be interested in...


Comments and Discussions

GeneralMy vote of 5 Pin
Gaby Mora G3-May-13 15:35
memberGaby Mora G3-May-13 15:35 
GeneralMy vote of 1 Pin
Alex Cherkasov26-Sep-12 16:12
memberAlex Cherkasov26-Sep-12 16:12 
GeneralMy vote of 2 Pin
ido.ran3-Mar-12 11:21
memberido.ran3-Mar-12 11:21 
GeneralMy vote of 4 Pin
crystalmac3-Mar-12 5:49
membercrystalmac3-Mar-12 5:49 
GeneralShellExecute [modified] Pin
DizZ22-Mar-10 5:42
memberDizZ22-Mar-10 5:42 
GeneralStart the .application click once file Pin
Adam Stechschulte19-Feb-10 6:13
memberAdam Stechschulte19-Feb-10 6:13 
GeneralAwesome! Pin
md5sum11-Feb-10 10:57
membermd5sum11-Feb-10 10:57 
GeneralURI formats are not supported [modified] Pin
Member 446494210-Aug-09 13:50
memberMember 446494210-Aug-09 13:50 
GeneralRe: URI formats are not supported Pin
José Luis Márquez10-Aug-09 14:12
memberJosé Luis Márquez10-Aug-09 14:12 
GeneralLanguage Pin
Member 446494210-Aug-09 6:57
memberMember 446494210-Aug-09 6:57 
GeneralRe: Language Pin
sandal_tolk27-Aug-09 21:55
membersandal_tolk27-Aug-09 21:55 
AnswerRe: Language Pin
polleke_Gent28-Oct-09 1:06
memberpolleke_Gent28-Oct-09 1:06 
GeneralRe: Language Pin
DizZ22-Mar-10 5:50
memberDizZ22-Mar-10 5:50 
GeneralCan't have Arguments Pin
dbrenth6-May-08 9:06
memberdbrenth6-May-08 9:06 
GeneralRe: Can't have Arguments Pin
dwrogers6-May-08 20:26
memberdwrogers6-May-08 20:26 
AnswerRe: Can't have Arguments [modified] Pin
Babba7216-Jul-09 22:45
memberBabba7216-Jul-09 22:45 

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

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

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170308.1 | Last Updated 29 Apr 2008
Article Copyright 2008 by dwrogers
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid