如何检查IIS 6管理兼容性功能是否已经安装? [英] How do I check whether IIS 6 Management Compatibility feature has been installed?

查看:2898
本文介绍了如何检查IIS 6管理兼容性功能是否已经安装?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

无论使用哪种VB.NET,C#,或VBScript,我怎么能检查IIS 6管理兼容性功能及其子功能已经被安装在计算机上运行IIS 7.x的?

Using either VB.NET, C#, or VBScript, how can I check if the IIS 6 Management Compatibility feature and its subfeatures have been installed on a machine running IIS 7.x?

推荐答案

我进行使用注册表车间的试用副本(比较注册管理功能)一些测试,发现如下:

I performed some tests using a trial copy of Registry Workshop (the Compare Registries function) and found the following:

如果安装了IIS 7.x中,下面的注册表项包含已安装的子组件的信息:

If IIS 7.x is installed, the following Registry key contains information about the installed subcomponents:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\InetStp\Components

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\InetStp\Components

每个安装特征被表示与双字节00000001的一个值。如果未安装的功能,缺少值

Each installed feature is represented with a value of DWORD 0x00000001. If a feature is not installed, the value is missing.

对于Web管理工具,该值名称如下:

For the Web Management Tools, the value names are as follows:

Web Management Tools
  IIS 6 Management Compatibility
    IIS 6 Management Console                              (LegacySnapin)
    IIS 6 Scripting Tools                                 (LegacyScripts)
    IIS 6 WMI Compatibility                               (WMICompatibility)
    IIS Metabase and IIS 6 configuration compatibility    (Metabase + ADSICompatibility)

  IIS Management Console                                  (ManagementConsole)
  IIS Management Scripts and Tools                        (ManagementScriptingTools)
  IIS Management Service                                  (AdminService)

请注意,这些组件的名称从Windows 7安装来,并可能会与Windows Server 2008中的略有不同,虽然注册表项应该是相同的。

Note that these component names came from a Windows 7 installation and might differ slightly from those of Windows Server 2008, though the Registry keys should be the same.

一些本在一份报告中提到的这篇文章:
使用托管代码检测是否安装IIS和ASP / ASP.NET被注册

Some of this is mentioned in a note to this article: Using Managed Code to Detect if IIS is Installed and ASP/ASP.NET is Registered

这些和其他子列表可以这里找到:安装Components\">发现

A list of these and other subcomponents can be found here: Discover Installed Components

更新:

从最终代码的一些核心功能。这不是完整的代码,但应该是足够的人谁花费的时间查找组件名称为各IIS版本:

Some core functions from the final code. This is not the complete code but should be enough for anyone who spends the time looking up the component names for the various IIS versions:

Function IsIISComponentInstalled(ByVal ComponentName)
    Dim result
    Dim intProcessorArchitecture
    intProcessorArchitecture = GetProcessorArchitectureIIS()
    If intProcessorArchitecture = 64 Then
        '64-bit system
        On Error Resume Next
        Err.Clear
        result = RegReadDWORD(HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\InetStp\Components", ComponentName, 64)
        If Err.Number <> 0 Then
            Err.Clear
            IsIISComponentInstalled = False
        Else
            If result = 1 Then
                IsIISComponentInstalled = True
            Else
                IsIISComponentInstalled = False
            End If
        End If
    Else
        '32-bit system
        If RegReadStringIIS("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\InetStp\Components\" & ComponentName) = "1" Then
            IsIISComponentInstalled = True
        Else
            IsIISComponentInstalled = False
        End If
    End If

End Function

Function GetProcessorArchitectureIIS()
    Dim strProcessorArchitecture
    Dim oShell

    Set oShell = CreateObject("Wscript.Shell")
    strProcessorArchitecture = oShell.RegRead("HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\PROCESSOR_ARCHITECTURE")

    If strProcessorArchitecture = "x86" Then
        GetProcessorArchitectureIIS = 32
    Else
        If strProcessorArchitecture = "AMD64" Then
            GetProcessorArchitectureIIS = 64
        Else
            GetProcessorArchitectureIIS = 0
        End If
    End If

End Function

Function RegReadStringIIS(sRegValue)
    Set oShell = CreateObject("WScript.Shell")
    On Error Resume Next
    RegReadStringIIS = oShell.RegRead(sRegValue)
    If Err Then
        RegReadStringIIS = ""
        Err.clear
    End If
    If VarType(RegReadStringIIS) < vbArray Then
        If RegReadStringIIS = sRegValue Then
            RegReadStringIIS = ""
        End If
    End If
    On Error Goto 0
End Function

'-------------------------------------------------------------------
' Reads a REG_SZ value from the local computer's registry using WMI.
' Parameters:
'   RootKey - The registry hive (see http://msdn.microsoft.com/en-us/library/aa390788(VS.85).aspx for a list of possible values).
'   Key - The key that contains the desired value.
'   Value - The value that you want to get.
'   RegType - The registry bitness: 32 or 64.
'
'References:
'   http://stackoverflow.com/questions/1229760/how-do-i-read-64-bit-registry-values-from-vbscript-running-as-a-an-msi-post-inst
'   http://msdn.microsoft.com/en-us/library/aa393067(VS.85).aspx
'   http://msdn.microsoft.com/en-us/library/windows/desktop/aa390445(v=VS.85).aspx
'
Function RegReadDWORD(RootKey, Key, Value, RegType)
    Dim oCtx, oLocator, oReg, oInParams, oOutParams
    Set oCtx = CreateObject("WbemScripting.SWbemNamedValueSet")
    oCtx.Add "__ProviderArchitecture", RegType
    Set oLocator = CreateObject("Wbemscripting.SWbemLocator")
    Set oReg = oLocator.ConnectServer("", "root\default", "", "", , , , oCtx).Get("StdRegProv")
    Set oInParams = oReg.Methods_("GetDWORDValue").InParameters
    oInParams.hDefKey = RootKey
    oInParams.sSubKeyName = Key
    oInParams.sValueName = Value
    Set oOutParams = oReg.ExecMethod_("GetDWORDValue", oInParams, , oCtx)
    RegReadDWORD = oOutParams.uValue
End Function

这篇关于如何检查IIS 6管理兼容性功能是否已经安装?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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