如何通过PowerShell运行appref-ms(ClickOnce)应用程序

3
我正试图创建一个 PowerShell 脚本,它将读取一个 XML 文件(服务器名称列表),然后在这些服务器上运行 ClickOnce 应用程序。在我的情况下,PowerShell 脚本执行将通过任务计划程序进行安排。
现在的问题是:我找不到通过 PowerShell 脚本运行 ClickOnce 应用程序的方法。
有什么想法吗?

你不能只使用 Start-Process 吗? - Adrian Rodriguez
4个回答

1

我通过在资源管理器中运行应用程序引用文件来运行它,例如:

$fileLocation="C:\temp\program.appref-ms"

explorer.exe $fileLocation


1
在多台机器上远程运行? - PreguntonCojoneroCabrón

1

本文记录了获取运行ClickOnce应用程序的文件路径的过程。

https://robindotnet.wordpress.com/2010/03/21/how-to-pass-arguments-to-an-offline-clickonce-application/

如果你能将这段C#/NET代码翻译成PowerShell,它应该可以工作。
StringBuilder sb = new StringBuilder();
sb.Append(Environment.GetFolderPath(Environment.SpecialFolder.Programs));
sb.Append("\\Nightbird");                       //ClickOnce Publisher name (eg Nightbird)
sb.Append("\\TestRunningWithArgs.appref-ms ");  //ClickOnce Product name (eg TestRunningWithArgs)
string shortcutPath = sb.ToString();
System.Diagnostics.Process.Start(shortcutPath, argsToPass);

0

您可以通过在iexplore.exe上启动进程并传递ClickOnce部署的URL来运行ClickOnce应用程序。您能在PowerShell中做到吗?如果可以,那么它应该可以工作。


ClickOnce 部署的 URL 是什么? - PreguntonCojoneroCabrón

0
试试这个: PowerShell "& Start-Process 'file://PATH_OF_YOUR.appref-ms'"

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接