Launching a ClickOnce application from another ClickOnce application
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:
SHELLEXECUTEINFO info = new SHELLEXECUTEINFO();
info.cbSize = System.Runtime.InteropServices.Marshal.SizeOf(info);
info.lpFile = ApplicationURL;
info.nShow = SW_SHOWNORMAL;
info.fMask = SEE_MASK_CLASSNAME;
info.lpClass = "Application.Manifest";
ShellExecuteEx(ref info);
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_ROOT\Application.Manifest).
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
.
Process.Start("rundll32.exe", "dfshim.dll,ShOpenVerbApplication " + ApplicationURL);
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.