8
votes

I'm 3-months new to WPF and trying to build a launchy app for fun (app launcher type thingie by name).

I can't seem to launch ClickOnce applications by Process name.

In other words:

  • Process.Start("Firefox"); // will work
  • Process.Start("MetroTwit"); // a ClickOnce app - will NOT work

I've read that you should be calling it by URL? But where do you find out the URL of the installed clickonce apps?

Ideally I'd want to refresh a List of apps installed on the users system (program files & clickonce & AIR clients) every minute or so and do fuzzy search on type etc.

Help greatly appreciated.

7

7 Answers

12
votes

You don't even need to parse the start folders. The location of that startup is here:

shortcutName = 
  string.Concat(Environment.GetFolderPath(Environment.SpecialFolder.Programs),
                "\\", publisher_name, "\\", product_name, ".appref-ms");

Where publisher_name and product_name are the ones set in the Options dialog in the publish properties.

5
votes

There are two kinds of ClickOnce applications (set when publishing the app) those that are installed on the start menu and those that can only be run from the web url.

Applications that are installed in the start menu can be found (surprisingly) under the start menu folder, they have special type of shortcut with the APPREF-MS extension.

You can use Process.Start to run the APPREF-MS file.

Application that are configured to only run from the web url, well, you have to run them from the web url.

3
votes

Process.Start is equivalent to doing Start, Run.. then entering some text there. You have to enter an executable that can be found using the PATH environment variable, or you can specify the URL that points to the .application file you want to run. E.g. http://publish.url.com/publish/myapp.application.

Hope that helps!

3
votes

Imho, the best way is that :

Process.Start("rundll32.exe", "dfshim.dll,ShOpenVerbApplication " + ApplicationURL); 
2
votes

To add to @Kieren's answer: the reason that Process.Start("Firefox") works is that Firefox installs itself in the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\firefox.exe key in the registry.

1
votes

The URL you are looking for is the URL used for installation. Yes, it sounds strange. ClickOnce is a bit strange. Unfortunately ClickOnce does not install to the Program Files folder but instead burries itself in a users AppData Folder. Depending on whether you installed via the web or through the CD/DVD option and will determine how easy it is to resolve this. Good luck!

-1
votes

Here is how to launch a clickonce app and it works everytime.

System.Diagnostics.Process.Start("http://webinstalls.somecompany.com/LApproval/StartApproval.application");