How to check if PowerShell is installed or not using C#

This question already has an answer here:

  • Determine installed PowerShell version 23 answers

  • 使用MSDN博客文章PowerShell安装的检测逻辑,我写了如下方法:

    public bool PowershellExists()
    {
        string regval = Microsoft.Win32.Registry.GetValue(@"HKEY_LOCAL_MACHINESOFTWAREMicrosoftPowerShell1", "Install", null).ToString();
        if (regval.Equals("1"))
            return true;
        else
            return false;
    }
    
    链接地址: http://www.djcxy.com/p/29004.html

    上一篇: 如何开始使用PowerShell?

    下一篇: 如何检查PowerShell是否安装或不使用C#