I'd like to be able to start a ClickOnce application from another executable. I know how to do this with the browser using Process.Start("http://PathToMyApp"). However, this is returning null for the Process. Therefore, I cannot check to ensure that the process has started or kill the process later.
How can I launch a click once application and get its Process Id开发者_如何学Python and determine whether or not it launched successfully?
You have to find the shortcut for the ClickOnce application and do a process.start on that. Here's an example:
string shortcutName =
string.Concat(Environment.GetFolderPath(Environment.SpecialFolder.Programs),
"\\", PublisherName, "\\", ProductName, ".appref-ms");
process.Start(shortcutName);
where PublisherName and ProductName are those filled in on the Options dialog in the Publish tab for the application you want to start.
You can also pass arguments to a ClickOnce application if you start it this way, even if it's offline. Here is an article telling how to do that just in case you need that functionality as well.
精彩评论