Install Clickonce Programmatically Using Google
- Install Clickonce Programmatically Using Google Account
- Install Clickonce Programmatically Using Google Search
Tutorial: How to Create, Publish and Update a Windows Forms Application using Clickonce in Visual Studio.
ClickOnce provides two ways to update an application once it is deployed. In the first method, you can configure the ClickOnce deployment to check automatically for updates at certain intervals. In the second method, you can write code that uses the ApplicationDeployment class to check for updates based on an event, such as a user request.
The following procedures show some code for performing a programmatic update and also describe how to configure your ClickOnce deployment to enable programmatic update checks.
Install Clickonce Programmatically Using Google Account
In order to update a ClickOnce application programmatically, you must specify a location for updates. This is sometimes referred to as a deployment provider. For more information on setting this property, see Choose a ClickOnce update strategy.
Note
You can also use the technique described below to deploy your application from one location but update it from another. For more information, see How to: Specify an alternate location for deployment updates.
To check for updates programmatically
Create a new Windows Forms application using your preferred command-line or visual tools.
Create whatever button, menu item, or other user interface item you want your users to select to check for updates. From that item's event handler, call the following method to check for and install updates.
Compile your application.
Use Mage.exe to deploy an application that checks for updates programmatically
Follow the instructions for deploying your application using Mage.exe as explained in Walkthrough: Manually deploy a ClickOnce application. When calling Mage.exe to generate the deployment manifest, make sure to use the command-line switch
providerUrl, and to specify the URL where ClickOnce should check for updates. If your application will update from http://www.adatum.com/MyApp, for example, your call to generate the deployment manifest might look like this:
Using MageUI.exe to deploy an application that checks for updates programmatically
- Follow the instructions for deploying your application using Mage.exe as explained in Walkthrough: Manually deploy a ClickOnce application. On the Deployment Options tab, set the Start Location field to the application manifest ClickOnce should check for updates. On the Update Options tab, clear the This application should check for updates check box.
.NET Framework Security
Your application must have full-trust permissions to use programmatic updating.
See also
My goal is to actually achieve launching my ClickOnce application in one click (or two I guess). The application has some prerequisites which need to be installed. The normal way of ensuring they are installed that Microsoft provides involves having the user decide whether he has the prerequisites or not and downloading and installing a 'setup.exe' which installs them and runs the ClickOnce application. This involves downloading the EXE file (one click), running it (two clicks), then after prerequisites are installed, clicking again to run the ClickOnce application.
I'm trying to reduce this process to one or two clicks:- Click a link on my website to the ClickOnce .application file.- Click again to run it.
I have made ANOTHER ClickOnce application, which includes a setup.exe. It checks if the prerequisites are installed, and if they are it runs the other ClickOnce application automatically. If not, it runs the included setup.exe and then runs the other ClickOnce application.
My problem is that when I try to run the other ClickOnce application from this one, it simply opens my web browser and downloads the .application file without running it.
I'm trying to use the following to start the ClickOnce application from inside my C# code:
I just want this to automatically launch the application at ApplicationURL. Is there a way to skip the browser involvement that I'm seeing?
(My question is very similar to Stack Overflow question Run a ClickOnce application from a webpage without user action).
3 Answers
As pointed out in the comments, you can start the iexplore.exe process to launch a ClickOnce application without any dependency on the default browser. You can also launch the ClickOnce application the same way Windows Explorer launches it, using dfshim.dll.
There are a few other articles online that discuss using this strategy, but I did not find any official documenation of dfshim.dll,ShOpenVerbApplication.
- Another Stack Overflow question mentions using a custom .exe to install the .NET Framework and then launch a ClickOnce application via ShOpenVerbApplication.
- Scott Hanselman discusses ShOpenVerbApplication as the default file mapping for files with the application/x-ms-application MIME type in a post about Firefox and ClickOnce.
Update
As the other Stack Overflow question mentions, you can also use dfshim.dll's LaunchApplication command, which is documented on Microsoft's site. However, that command is not available in some older versions of the .NET Framework.
Have a look at the Microsoft walkthrough for installing manually via InPlaceHostingManager. You have the ability to customize programmatically.
Peter Mortensen
There are at least 2 other methods for launching ClickOnce applications.
One simple method is Process.Start('PresentationHost.exe', '-launchApplication ' + ApplicationURL); as documented by Microsoft here.
A more sophisticated method is calling ShellExecuteEx() Win32 API with code like this:
Install Clickonce Programmatically Using Google Search
Required Win32 API import and structure definitions can be found here. This method will query registry and run 'rundll32.exe dfshim.dll,ShOpenVerbApplication' (or anything else that is configured under HKEY_CLASSES_ROOTApplication.Manifest).