使用 FullTrustProcessLauncher 类从 UWP 应用启动 powershell 脚本 [英] Launch powershell script from UWP app with FullTrustProcessLauncher class

查看:42
本文介绍了使用 FullTrustProcessLauncher 类从 UWP 应用启动 powershell 脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

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

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

你有什么想法吗?

推荐答案

文档: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/树/主/示例/SQLServer

简而言之,您需要执行以下操作:

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

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

1) add reference to the Desktop Extension SDK

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

2) declare the windows.FullTrustProcess extension in your manifest

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

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

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

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

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

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

这篇关于使用 FullTrustProcessLauncher 类从 UWP 应用启动 powershell 脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆