如何在遠程計算機上運行 ClickOnce 應用程序 (.appref-ms)? (How to run a ClickOnce application (.appref-ms) on a remote computer?)


問題描述

如何在遠程計算機上運行 ClickOnce 應用程序 (.appref‑ms)? (How to run a ClickOnce application (.appref‑ms) on a remote computer?)

I am trying to launch a ClickOnce application via an .appref‑ms shortcut on a remote machine using WMI, but cannot succeed. The below code works fine if I try to run notepad.exe.

ManagementPath pm = new ManagementPath(@"\\server\root\cimv2:Win32_process");
ManagementClass processClass = new ManagementClass(pm);

//Get an input parameters object for this method
ManagementBaseObject inParams = processClass.GetMethodParameters("Create");

//Fill in input parameter values
inParams["CommandLine"] = @"C:\Documents and Settings\Start Menu\Programs\New\New App.appref‑ms";

//Execute the method
ManagementBaseObject outParams = processClass.InvokeMethod("Create", inParams, null);

‑‑‑‑‑

參考解法

方法 1:

Try launching the .appref‑ms shortcut via rundll32:

inParams["CommandLine"] = @"rundll32.exe dfshim.dll,ShOpenVerbShortcut ""C:\New App.appref‑ms"";

Alternatively, instead of relying on the shortcut path, you could use the application deployment URL (you can see it by opening the .appref‑ms file in a text editor):

inParams["CommandLine"] = @"rundll32.exe dfshim.dll,ShOpenVerbApplication http://github‑windows.s3.amazonaws.com/GitHub.application";

Keep in mind that Win32_Process.Create cannot create interactive processes remotely.

方法 2:

What is the error that you are getting. 

BTW, there seem to be two problems with the commandline path that you are using.

  1. Start Menu folder IMO is in C:\Documents and Settings\"Usernamehere"\StartMenu.
  2. I am not sure but I think that you can't run a program remotely which lies inside a user's profile. Try installing the program to some other location like your c:\program files and then try to call it.

Apart from that, if you mention the exact error you are getting, then it would be helpful to diagnose the problem.

(by Raj KumarHelenAamir)

參考文件

  1. How to run a ClickOnce application (.appref‑ms) on a remote computer? (CC BY‑SA 3.0/4.0)

#clickonce #remote-access #wmi #.net #C#






相關問題

ClickOnce 發布 (ClickOnce publishing)

如何在無需重新下載每個文件的情況下更新已部署的 clickonce 應用程序? (How do I update a deployed clickonce application without having to redownload every file?)

Bạn cần thực hiện các bước nào để tạo lại tệp kê khai khi sử dụng triển khai Nhấp Một lần (What steps do you need to take to regenerate the manifest when using Click Once deployment)

將 VS 2013 中的 WPF 應用程序發佈到 Programm Files 中——不可能嗎? (Publishing a WPF app in VS 2013 in to Programm Files -- impossible?)

ClickOnce部署,需要係統更新Microsoft.mshtml (ClickOnce Deployment, system update required Microsoft.mshtml)

ClickOnce 從緩存中安裝舊程序集 (ClickOnce installing old assemblies from cache)

使用 MSBuild 發布 ClickOnce 應用 (Publish ClickOnce app with MSBuild)

單擊一個發布 (Click one Release)

使用 PostSharp 1.0 的 ClickOnce 應用程序似乎需要 GAC 中的 1.5 程序集 (ClickOnce application that uses PostSharp 1.0 seems to require 1.5 assemblies in GAC)

如何在遠程計算機上運行 ClickOnce 應用程序 (.appref-ms)? (How to run a ClickOnce application (.appref-ms) on a remote computer?)

使用證書籤署 ClickOnce? (Signing ClickOnce with a certificate?)

不安裝證書可以使用 MSBuild 的 SignFile 嗎? (Can MSBuild's SignFile be used without installing the certificate?)







留言討論