问题
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 ?
回答1:
Docs: https://docs.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.
来源:https://stackoverflow.com/questions/44157327/launch-powershell-script-from-uwp-app-with-fulltrustprocesslauncher-class