问题
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.
My Question is
How to pass the parameter. I success to run Exe file on UWP, but the input full path for filename maybe wrong and failed.
in ViewModels,
await FullTrustProcessLauncher.LaunchFullTrustProcessForCurrentAppAsync("spectrum");
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>
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...." ??
Is there anyway to pass Argument in programmatically ? Honestly, I do not want to write argement in Package.appxmanifest.
Update 1: I tried this too. but can not find the filename.
<desktop:ParameterGroup GroupId="spectrum" Parameters=".\Assets\Identify\filename.txt"/>
Update 2
my external application show this error :
This mean, My external applicaiton received strange string as input argument. "*/InvokerPRAID : App Appx/identify/souma.spe"
What is /InvokerPRAID : App ??
回答1:
If you want to pass the parameter to the arguments of the Win32 application, the value is in the third argument.
UWP Package Manifest:
<desktop:ParameterGroup GroupId="spectrum" Parameters=".\Assets\Identify\filename.txt"/>
Win 32 Application
static void Main(string[] args)
{
//args[0] = "/InvokerPRAID :"
//args[1] = "App"
var fullTrustProcessParam = args[2]; //".\Assets\Identify\filename.txt"
}
来源:https://stackoverflow.com/questions/47765108/uwp-run-exe-file-with-parameters