UWP 运行带有参数的 exe 文件 [英] UWP run Exe file with Parameters
问题描述
在 UWP 上,我想运行一个带参数的 Exe 文件.这是一个例子.
on UWP, I want to run a Exe file with parameter. Here is an example.
process.exe filename.txt
此命令行应用程序处理文本文件并将结果文件输出为文本.
this Command line application process the text file and output a result file as Text.
我的问题是
如何传递参数.我在 UWP 上成功运行了 Exe 文件,但输入文件名的完整路径可能错误且失败.
How to pass the parameter. I success to run Exe file on UWP, but the input full path for filename maybe wrong and failed.
在视图模型中,
await FullTrustProcessLauncher.LaunchFullTrustProcessForCurrentAppAsync("spectrum");
在 Package.appxmanifest 中
in 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 找不到输入文件.
Now, I put a file on Assets\identify folder. it is same folder with exe file. but Exefile can not find the input file.
我应该如何在桌面:参数组...."中写入??
How should I write in "desktop:ParameterGroup...." ??
无论如何要以编程方式传递 Argument 吗?老实说,我不想在 Package.appxmanifest 中写参数.
Is there anyway to pass Argument in programmatically ? Honestly, I do not want to write argement in Package.appxmanifest.
更新 1:我也试过这个.但找不到文件名.
Update 1: I tried this too. but can not find the filename.
<desktop:ParameterGroup GroupId="spectrum" Parameters=".\Assets\Identify\filename.txt"/>
更新 2
我的外部应用程序显示此错误:
my external application show this error :
这意味着,我的外部应用程序收到奇怪的字符串作为输入参数."*/InvokerPRAID : App Appx/identify/souma.spe"
This mean, My external applicaiton received strange string as input argument. "*/InvokerPRAID : App Appx/identify/souma.spe"
什么是/InvokerPRAID:应用程序??
What is /InvokerPRAID : App ??
推荐答案
如果要将参数传递给 Win32 应用程序的参数,则该值在第三个参数中.
If you want to pass the parameter to the arguments of the Win32 application, the value is in the third argument.
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"
}
这篇关于UWP 运行带有参数的 exe 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!