Powershell 与 Python(不是 IronPython)集成

发布于 2024-10-08 00:30:20 字数 195 浏览 0 评论 0原文

我知道可以在 IronPython 中使用 Powershell,但是除了使用 Popen() 和其他类似调用之外,是否可以使用 CPython?我正在尝试做一些非常基本的 NET 框架编程(Windows Forms 等),就像您可以使用 CPython 在 IronPython 中所做的那样。

谢谢!

任何帮助表示赞赏。

I know it is possible to use Powershell from within IronPython, but is this possible using CPython beyond using Popen() and other similar calls? I'm trying to do some very basic NET framework programming (windows Forms, etc.) like you can do inside of IronPython using CPython.

Thanks!

Any help appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

阪姬 2024-10-15 00:30:20

我不确定你为什么被否决,因为这是一个合理的问题。我认为尝试将 PowerShell 集成到 CPython 中的最佳集成是生成一个新进程并传入您想要运行的 PowerShell 脚本。不幸的是,这也意味着解析生成的任何输出。没有一个 COM 或 C 库可以真正链接到以获得更好的效果。

可能有某种用于 CPython 的通用 .NET 互操作库(我还没有检查),但这可能是一个选项,使用该层您可以(至少在理论上)使用与将 PowerShell 运行时嵌入到相同的技术常规 .NET 应用程序。

I am not sure why you got downvoted as this is a legitimate question. I think the best integration you are going to get trying to integrate PowerShell into CPython will be through spawning a new process and passing in the PowerShell script you want run. Unfortunately this will also mean parsing any output that is generated as well. There is not a COM or C library you can really link against to get much better.

There might be some sort of a general .NET interop library for CPython (I haven't checked), but that may be an option, using that layer you could (at least in theory) use the same techniques as embedding the PowerShell runtime into a regular .NET App.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文