如何使用VB.NET,C#或VBScript,如何檢查IIS 6管理兼容性功能及其子功能是否已安裝在運行IIS 7.x的計算機上?如何檢查IIS 6管理兼容性功能是否已安裝?
4
A
回答
8
我進行使用註冊表研討會(比較登記處功能)的試用版一些測試,發現如下:
如果安裝了IIS 7.x中,以下注冊表項包含有關安裝的子組件的信息:
HKEY_LOCAL_MACHINE \ SOFTWARE \微軟\ InetStp \組件
每個已安裝的功能表示用DWORD 00000001的值。如果某個功能未安裝,則該值缺失。
對於Web管理工具,該值名稱如下:
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中的略有不同,雖然註冊表項應該是一樣的。
一些這方面在一份報告中提到的這篇文章: Using Managed Code to Detect if IIS is Installed and ASP/ASP.NET is Registered
這些和其他子組件列表可以在這裏找到: Discover Installed Components
更新:
一些核心功能從最終的代碼。這是不完整的代碼,但應該是足夠的人誰花費的時間查找組件名稱爲各IIS版本:
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
相關問題
- 1. 檢測是否安裝了IIS 6.0元數據庫兼容性
- 2. 檢查IIS是否安裝?
- 3. 如何檢查sqlite2是否已安裝?
- 4. 如何檢查ncurses是否已安裝?
- 5. 安裝jar檢查是否已安裝
- 6. 客戶端兼容性檢查管理
- 7. IIS 6:如何檢查服務器跟蹤是否已啓用?
- 8. 已安裝Subclipse for Eclipse - 如何檢查它是否安裝成功?
- 9. 檢查點是否已安裝?
- 10. 檢查SQL Server是否已安裝C#
- 11. 檢查管理員是否已登錄
- 12. 如何檢查IIS 7或7+是否已安裝或未使用innosetup?
- 13. 管理程序兼容性
- 14. 如何檢查頁面是否已安裝在檢票口?
- 15. 檢查產品是否安裝成功
- 16. 在安裝IIS 6配置數據庫和IIS 6配置兼容性時出現錯誤
- 17. 爲Sql Server安裝全文功能(兼容性問題)
- 18. 如果安裝了IIS功能,如何檢入WiX?
- 19. 如何檢查Mininet是否已成功安裝在我的電腦上?
- 20. 不能刪除已安裝從管理
- 21. 如何檢查BLAS和ATLAS是否已經安裝
- 22. 如何檢查軟件是否已安裝
- 23. WLST - 如何檢查補丁是否已安裝?
- 24. PHP:如何檢查庫是否已正確安裝並啓用?
- 25. 如何檢查應用程序是否已安裝?
- 26. 如何檢查我是否已正確安裝Android SDK?
- 27. 如何檢查包是否已安裝在Ubuntu?
- 28. 如何檢查R是否已安裝在Ubuntu中?
- 29. 如何檢查Expression Encoder 4是否已安裝?
- 30. 如何檢查Perl模塊(DBD :: mysql)是否已正確安裝?
在VBS或PowerShell的PS1完整的源代碼示例任何最終的解決方案? – Kiquenet 2014-01-13 11:51:10
不,我沒有一小段示例代碼,整個過程太長而無法發佈。 – 2014-01-14 08:12:49
很遺憾,也許使用dropbox或github。 – Kiquenet 2014-01-14 08:16:57