简体   繁体   English

如何检测是否安装了 Powershell Core 以及 C# 中的哪个版本?

[英]How to detect if Powershell Core is installed and what version in C#?

With Windows Powershell it is possible to lookup the installed version within the registry.使用 Windows Powershell,可以在注册表中查找已安装的版本。

Using C#, what is the most reliable way to determine if Powershell Core (6+) is available on a system, as well as what version?使用 C#,确定系统上是否提供 Powershell Core (6+) 以及哪个版本的最可靠方法是什么?

Note: I appreciate it can be deployed via zip which complicates this, so specifically looking for "installed" instances.注意:我很欣赏它可以通过 zip 部署,这使这变得复杂,所以专门寻找“已安装”的实例。

Here is a similar question to yours: Get installed applications in a system .这是一个与您类似的问题: 在系统中获取已安装的应用程序 It talks more generally about getting installed applications with C#, but you should be able to adapt it to fit your needs.它更广泛地讨论了使用 C# 安装应用程序,但您应该能够对其进行调整以满足您的需求。

Powershell Core v6+ & v7+ show up in the installed programs list separately unlike the Powershell install embedded in Windows.与嵌入在 Windows 中的 Powershell 安装不同,Powershell Core v6+ 和 v7+ 分别显示在已安装的程序列表中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM