使用 FullTrustProcessLauncher class 从 UWP 应用启动 powershell 脚本

Launch powershell script from UWP app with FullTrustProcessLauncher class

有没有办法从我的 UWP 应用启动 powershell 脚本?

我了解到我们必须使用 FullTrustProcessLauncher class 但我不明白如何 use/implement 它。

你有什么想法吗?

文档:https://docs.microsoft.com/en-us/uwp/api/Windows.ApplicationModel.FullTrustProcessLauncher

样本: 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

简而言之,这是您需要做的:

1) 添加对桌面扩展 SDK 的引用

2) 在您的清单中声明 windows.FullTrustProcess 扩展

3)(可选)声明一个应用服务,用于在您的 UWP 和完全信任进程之间进行通信

4) 在您的程序包中包含一个 Win32 EXE,它将从 FullTrustProcessLauncher API

启动

5) Win32 EXE 现在可以调用您的 powershell 等