uwpdesktop-bridge

Launch powershell script from UWP app with FullTrustProcessLauncher class


Is there a way to launch powershell script from my UWP app ?

I have read that we have to use the FullTrustProcessLauncher class but I don't understand how to use/implement it.

Do you have any idea ?


Solution

  • Docs: https://learn.microsoft.com/en-us/uwp/api/Windows.ApplicationModel.FullTrustProcessLauncher

    Samples: https://github.com/Microsoft/DesktopBridgeToUWP-Samples/tree/master/Samples/AppServiceBridgeSample

    https://github.com/Microsoft/DesktopBridgeToUWP-Samples/tree/master/Samples/JourneyAcrossTheBridge/DesktopBridgeDemo%20-%20Step4/MyUWPApp

    https://github.com/Microsoft/DesktopBridgeToUWP-Samples/tree/master/Samples/SQLServer

    In a nutshell, here is what you need to do:

    1) add reference to the Desktop Extension SDK

    2) declare the windows.FullTrustProcess extension in your manifest

    3) (optional) declare an app service for communicating between your UWP and the fulltrust process

    4) include a Win32 EXE in your package that will get launched from the FullTrustProcessLauncher API

    5) that Win32 EXE can now invoke your powershell, etc.