简体   繁体   English

C# - Process.Start一个ClickOnce应用程序? 什么网址?

[英]C# - Process.Start a ClickOnce application? What URL?

I'm 3-months new to WPF and trying to build a launchy app for fun (app launcher type thingie by name). 我已经为WPF做了3个月的新手,并尝试构建一个有趣的appy应用程序(app name launcher type thingie by name)。

I can't seem to launch ClickOnce applications by Process name. 我似乎无法按进程名称启动ClickOnce应用程序。

In other words: 换一种说法:

  • Process.Start("Firefox"); 的Process.Start( “火狐”); // will work // 将工作
  • Process.Start("MetroTwit"); 的Process.Start( “MetroTwit”); // a ClickOnce app - will NOT work // ClickOnce应用程序 - 不起作用

I've read that you should be calling it by URL? 我读过你应该用URL调用它吗? But where do you find out the URL of the installed clickonce apps? 但是,您在哪里找到已安装的clickonce应用程序的URL?

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. 理想情况下,我想每分钟刷新一次安装在用户系统上的应用程序列表(程序文件&clickonce和AIR客户端),并对类型等进行模糊搜索。

Help greatly appreciated. 非常感谢。

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. 其中publisher_name和product_name是发布属性中“选项”对话框中设置的名称。

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. ClickOnce应用程序(在发布应用程序时设置)有两种安装在开始菜单上的应用程序和只能从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. 安装在开始菜单中的应用程序可以在开始菜单文件夹下找到(令人惊讶),它们具有APPREF-MS扩展名的特殊类型的快捷方式。

You can use Process.Start to run the APPREF-MS file. 您可以使用Process.Start运行APPREF-MS文件。

Application that are configured to only run from the web url, well, you have to run them from the web url. 配置为仅从Web URL运行的应用程序,您必须从Web URL运行它们。

Process.Start is equivalent to doing Start, Run.. then entering some text there. Process.Start相当于执行Start,Run ..然后在那里输入一些文本。 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. 您必须输入可使用PATH环境变量找到的可执行文件,或者您可以指定指向要运行的.application文件的URL。 Eg http://publish.url.com/publish/myapp.application . 例如http://publish.url.com/publish/myapp.application

Hope that helps! 希望有所帮助!

要添加到@Kieren的答案: Process.Start("Firefox")工作原理是Firefox将自己安装在HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\firefox.exe中的HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\firefox.exe项中。

The URL you are looking for is the URL used for installation. 您要查找的URL是用于安装的URL。 Yes, it sounds strange. 是的,听起来很奇怪。 ClickOnce is a bit strange. ClickOnce有点奇怪。 Unfortunately ClickOnce does not install to the Program Files folder but instead burries itself in a users AppData Folder. 不幸的是,ClickOnce不会安装到Program Files文件夹中,而是将其自身隐藏在用户的AppData文件夹中。 Depending on whether you installed via the web or through the CD/DVD option and will determine how easy it is to resolve this. 取决于您是通过Web安装还是通过CD / DVD选项安装,并将确定解决此问题的难易程度。 Good luck! 祝好运!

Imho,最好的方法是:

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

以下是如何启动clickonce应用程序,它每次都有效。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM