【问题标题】:Launch powershell script from UWP app with FullTrustProcessLauncher class使用 FullTrustProcessLauncher 类从 UWP 应用启动 powershell 脚本
【发布时间】:2017-10-24 17:39:36
【问题描述】:

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

我读到我们必须使用 FullTrustProcessLauncher 类,但我不明白如何使用/实现它。

你有什么想法吗?

【问题讨论】:

    标签: uwp desktop-bridge


    【解决方案1】:

    文档: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 等。

    【讨论】:

    • 我试过这样做,但它必须作为控制台应用程序运行吗?将后台进程更改为 Windows 应用程序不起作用
    • 请提出一个新问题,详细说明您尝试过的方法以及不适合您的方法。您可以将 Win32 进程设置为控制台应用程序或 Windows 应用程序,具体取决于您要为用户创建的体验。
    猜你喜欢
    • 2010-12-20
    • 1970-01-01
    • 2019-06-16
    • 2016-02-01
    • 2011-01-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-18
    相关资源
    最近更新 更多