【问题标题】:UWP run Exe file with ParametersUWP 运行带参数的 Exe 文件
【发布时间】:2017-12-12 03:54:14
【问题描述】:

在 UWP 上,我想运行一个带参数的 Exe 文件。 这是一个例子。

process.exe filename.txt

此命令行应用程序处理文本文件并将结果文件输出为文本。

我的问题是

如何传递参数。我成功在 UWP 上运行 Exe 文件,但文件名的输入完整路径可能错误并失败。

在 ViewModel 中,

await FullTrustProcessLauncher.LaunchFullTrustProcessForCurrentAppAsync("spectrum");

在 Package.appxmanifest 中

  <Extensions>
    <desktop:Extension Category="windows.fullTrustProcess" Executable="Assets\identify\process.exe" >
      <desktop:FullTrustProcess>
        <desktop:ParameterGroup GroupId="spectrum" Parameters="Assets\Identify\filename.txt"/>
      </desktop:FullTrustProcess>
    </desktop:Extension>
  </Extensions>
...
<Capabilities>
<rescap:Capability Name="runFullTrust" />
</DeviceCapability>

现在,我将文件放在 Assets\identify 文件夹中。它与exe文件是同一个文件夹。 但是Exefile找不到输入文件。

“desktop:ParameterGroup....”应该怎么写??

有没有以编程方式传递参数? 老实说,我不想在 Package.appxmanifest 中写参数。

更新 1: 我也试过这个。但找不到文件名。

        <desktop:ParameterGroup GroupId="spectrum" Parameters=".\Assets\Identify\filename.txt"/>

更新 2

我的外部应用程序显示此错误:

这意味着,我的外部应用程序收到了奇怪的字符串作为输入参数。 "*/InvokerPRAID : 应用 Appx/identify/souma.spe"

什么是 /InvokerPRAID : 应用程序??

【问题讨论】:

标签: uwp desktop-bridge


【解决方案1】:

如果要将参数传递给 Win32 应用程序的参数,则值在第三个参数中。

UWP 包清单:

<desktop:ParameterGroup GroupId="spectrum" Parameters=".\Assets\Identify\filename.txt"/>

Win 32 应用程序

static void Main(string[] args)
{
   //args[0] = "/InvokerPRAID :"
   //args[1] = "App"
   var fullTrustProcessParam = args[2]; //".\Assets\Identify\filename.txt"
}

【讨论】:

  • 如何通过公共 MainWindow 初始化方法将参数传递到我的 UWP 应用程序? IE:我的 XAML UWP 应用程序使用自定义 Web 协议 myProtocol://Launcher?user=userId&amp;eventId=eventId; 或通过另一个调用 Process.Start("c:/ProgramFiles/MyCompany/MyApp.exe") 的应用程序启动
猜你喜欢
  • 1970-01-01
  • 2015-05-18
  • 2015-01-01
  • 2011-10-23
  • 2014-05-31
  • 2013-04-02
  • 2018-09-27
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多