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!
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
The EXE needs to be included in the appx package, and declared in the appxmanifest. Also make sure you declare the 'runFullTrust' capability in the appxmanifest. That's all you need. If that doesn't help, please ask a more detailed question, so we understand what exactly doesn't work for you.
MSDN documentation: https://learn.microsoft.com/en-us/uwp/api/Windows.ApplicationModel.FullTrustProcessLauncher
GitHub samples that use this feature:
https://github.com/Microsoft/DesktopBridgeToUWP-Samples/tree/master/Samples/AppServiceBridgeSample
https://github.com/Microsoft/DesktopBridgeToUWP-Samples/tree/master/Samples/AppServiceBridgeSample_C%2B%2B
https://github.com/Microsoft/DesktopBridgeToUWP-Samples/tree/master/Samples/SQLServer
https://github.com/Microsoft/DesktopBridgeToUWP-Samples/tree/master/Samples/UWP%20Office%20Interop
https://github.com/Microsoft/DesktopBridgeToUWP-Samples/tree/master/Samples/UWP%20Systray
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With