2016年1月22日 星期五

新增IE相容性檢視網站VBS


1. 先在一台電腦上的IE新增欲加入相容性檢視的網站,例如172.16.1.20

2. 匯出 HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\BrowserEmulation\ClearableListData 登錄檔,匯出後會是一堆的16進位值如下:

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\BrowserEmulation\ClearableListData]
"UserFilter"=hex:41,1f,00,00,53,08,ad,ba,01,00,00,00,34,00,00,00,01,00,00,00,\
  01,00,00,00,0c,00,00,00,9a,7b,6c,ff,d8,54,d1,01,01,00,00,00,0b,00,31,00,37,\
  00,32,00,2e,00,31,00,36,00,2e,00,31,00,2e,00,32,00,30,00

3. 將底下的 strHexValues 改成上面的16進位值,並另存為 CompatibilityView.vbs
========================================================================
On Error Resume Next

Const HKEY_CURRENT_USER = &H80000001

strComputer = "."

Set objReg = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}\\" & strComputer & _
        "\root\default:StdRegProv")

strKeyPath = "Software\Microsoft\Internet Explorer\BrowserEmulation\ClearableListData"

objReg.CreateKey HKEY_CURRENT_USER,strKeyPath

strValueName = "UserFilter"

strHexValues = "hex:41,1f,00,00,53,08,ad,ba,01,00,00,00,34,00,00,00,01,00,00,00,01,00,00,00,0c,00,00,00,9a,7b,6c,ff,d8,54,d1,01,01,00,00,00,0b,00,31,00,37,00,32,00,2e,00,31,00,36,00,2e,00,31,00,2e,00,32,00,30,00"

arrHexValues = Split(Replace(strHexValues, "hex:", ""), ",")
arrDecValues = DecimalNumbers(arrHexValues)

objReg.SetBinaryValue HKEY_CURRENT_USER,strKeyPath,strValueName,arrDecValues

Function DecimalNumbers(arrHex)
   Dim i, strDecValues
   For i = 0 to Ubound(arrHex)
     If isEmpty(strDecValues) Then
       strDecValues = CLng("&H" & arrHex(i))
     Else
       strDecValues = strDecValues & "," & CLng("&H" & arrHex(i))
     End If
   next
   DecimalNumbers = split(strDecValues, ",")
End Function
========================================================================

4. 只要在欲設定相容性檢視的電腦執行 CompatibilityView.vbs 就可以完成


參考資料 http://www.adilhindistan.com/2011/09/writing-binary-data-to-registry.html

沒有留言:

張貼留言