如何在所有平台中的C#中运行PowerShell命令

发布于 2025-01-28 04:28:39 字数 551 浏览 3 评论 0原文

我想在简单的控制台应用程序上运行Power Shell命令。

我正在运行x64平台。

当我使用Anycpu选项运行时,它不起作用。

我得到错误pnputil:术语“ pnputil”一词不被识别为cmdlet的名称,

如果我使用x64选项运行,则该名称正在工作。

我如何运行该应用程序,以便它可以在平台上使用(例如x32,x64)

而无需手动指定?

谢谢你。

edit

我可以用 this 。但不要因为它不安全。

I want to run power shell command on a simple console app.

I'm running on x64 platform.

As I'm running with AnyCpu option it's not working.

I'm getting error pnputil : The term 'pnputil' is not recognized as the name of a cmdlet,

If i'm running with x64 option it's working.

How can I run the application so it'll work on platforms(e.g on x32 , x64)

Without specifying manually?

Thank You.

Edit:

I can solve it with something like this. but don't want as it's not safe.

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文