How to launch .exe file in uwp app using fulltrustlauncher?

14.7k views Asked by At

for now, i need to execute a .exe file in my uwp app. I know a solution is using fulltrustlauncher, but i have searched for many times for this solution, but my programming level seem too low, so It is very difficult for me to understand their explaination (for example: Running an EXE from C# using UWP ). So, how do you have a simple sample code for this solution? can you sharing?
Thank you!

2

There are 2 answers

0
Stefan Wick  MSFT On
4
GIANGPZO On

Finally, I can launch my .exe file in my UWP Application. I will describe my workaround step by step like this:
1. Create your executable .exe file (for example console application)
2. copy .exe file to your UWP Application start up folder (for example: Assets folder)
3. In UWP App Solution Explorer, add reference to "Windows Desktop Extensions For The UWP v10.0.14393.0"(or higher) under "References > Universal Windows > Extensions".
4. In UWP App Solution Explorer, open Package.appxmanifest xml file (right click on Package.appxmanifest file --> view code). add these namespace

xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities" xmlns:desktop="http://schemas.microsoft.com/appx/manifest/desktop/windows10"

to Package tag. And then, add this extension:

<Extensions>
    <desktop:Extension Category="windows.fullTrustProcess" Executable="Assets\YourExecutableFileName.exe" />
</Extensions>

under Application tag. And then, add this code:

<rescap:Capability Name="runFullTrust" />

into your Capabilities tag. this step mean: talk to compiler to know that it shuld trust your .exe file in the Assets\YourExecutableFileName.exe location.
5. In your UWP Application whenever you want to launch the .exe file, you need to execute this code:

await FullTrustProcessLauncher.LaunchFullTrustProcessForCurrentAppAsync();

reference:Great answer