3流プログラマのメモ書き

元開発職→社内SE→派遣で営業支援の三流プログラマのIT技術メモ書き。 このメモが忘れっぽい自分とググってきた技術者の役に立ってくれれば幸いです。(jehupc.exblog.jpから移転中)

(WSH)IEのJava2SSVアドオンを無効にするスクリプト

ユーザよりIE8でページ表示が遅いという問い合わせがあり、調査した結果アドオンの"Java(tm) Plug-In 2 SSV Helper"が原因であるということがわかりました。
これは、Javaのセキュリティチェックを行うプラグインのようですが、あまりに遅いのでとりあえず無効化することとしました。("Java(tm) Plug-In SSV Helper"プラグインもついでに無効化します)
IEの以下はアドオンの管理からコピペした情報です。

名前:           Java(tm) Plug-In 2 SSV Helper
発行元:          Sun Microsystems, Inc.
種類:           ブラウザー ヘルパー オブジェクト
バージョン:        6.0.310.5
ファイル日付:       
最終アクセス日:      2012年4月24日9:01
Class ID:     {DBC80044-A445-435B-BC74-9C25C1C588A9}
使用回数:         203
ブロック回数:       1
ファイル:         jp2ssv.dll
フォルダー:        C:\Program Files (x86)\Java\jre6\bin


名前:           Java(tm) Plug-In SSV Helper
発行元:          Sun Microsystems, Inc.
種類:           ブラウザー ヘルパー オブジェクト
バージョン:        6.0.310.5
ファイル日付:       
最終アクセス日:      2012年4月24日14:35
Class ID:     {761497BB-D6F0-462C-B6EB-D4DAF1D92D43}
使用回数:         991
ブロック回数:       0
ファイル:         ssv.dll
フォルダー:        C:\Program Files\Java\jre6\bin

しかし、ユーザにいちいち設定させていたのでは面倒なので、スクリプトとかで一括して設定できないか調査したところ、MicrosoftMS Technet:AddOn-wmi.vbsというサンプルのVBScriptを掲載していました。

WMIを使ってレジストリに無効化フラグを挿入するというもののようです。
IEのアドオンの管理から、アドオンのClassIDがわかるので、そのClassIDを g_strKeyPathA , g_strKeyPathB に指定して動かせばOKです。
これを各ユーザのログオンスクリプトに仕込むことにしました。

丸コピペですが、VBScriptを一応乗せておきます。(ログオンスクリプトにするのでエラー表示は出さないようにしています)

On Error Resume Next

Dim strUserName,objNet

'Global constants and variables
Const HKEY_CURRENT_USER = &H80000001
strComputer = "." ' Can be changed to name of remote computer.
g_strKeyPathA = "Software\Microsoft\Windows" & _
 "\CurrentVersion\Ext\Settings\{DBC80044-A445-435B-BC74-9C25C1C588A9}"
g_strKeyPathB = "Software\Microsoft\Windows" & _
 "\CurrentVersion\Ext\Stats\{DBC80044-A445-435B-BC74-9C25C1C588A9}\iexplore"

'Connect with WMI service and StdRegProv class.
Set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
 strComputer & "\root\default:StdRegProv")
If Err = 0 Then
  blnCreateSubKeys = CreateSubKeys
  If blnCreateSubKeys Then
    SetValues
  End If
'Else
'  WScript.Echo "Unable to connect to WMI service on " & strComputer & "."
'  WScript.Echo Err.Number
'  WScript.Echo Err.Source
'  WScript.Echo Err.Description
End If


g_strKeyPathA = "Software\Microsoft\Windows" & _
 "\CurrentVersion\Ext\Settings\{761497BB-D6F0-462C-B6EB-D4DAF1D92D43}"
g_strKeyPathB = "Software\Microsoft\Windows" & _
 "\CurrentVersion\Ext\Stats\{761497BB-D6F0-462C-B6EB-D4DAF1D92D43}\iexplore"

If Err = 0 Then
  blnCreateSubKeys = CreateSubKeys
  If blnCreateSubKeys Then
    SetValues
  End If
End If

Err.Clear


'******************************************************************************
'AddOn-wmi.vbs
'Author: Peter Costantini, the Microsoft Scripting Guys
'Date: 8/25/04
'Revision 1.0
'This script edits the registry to disable a specific Internet Explorer
'add-on. You must edit the registry path to insert the correct CLSID of
'the add-on component to be disabled. To identify the CLSID of an add-on
'component, search the registry for the add-on name that is located in the
'Manage Add-ons interface.
'******************************************************************************



'******************************************************************************

Function CreateSubKeys

intReturnA = objReg.CreateKey(HKEY_CURRENT_USER, g_strKeyPathA)
If intReturnA <> 0 Then
'  WScript.Echo "ERROR: Unable to create registry path:" & VbCrLf & _
'   "HKEY_CURRENT_USER\" & strKeyPathA
End If
intReturnB = objReg.CreateKey(HKEY_CURRENT_USER, g_strKeyPathB)
If intReturnB <> 0 Then
'  WScript.Echo VbCrLf & "ERROR: Unable to create registry path:" & VbCrLf & _
'   "HKEY_CURRENT_USER\" & strKeyPathB
End If
If (intReturnA = 0) And (intReturnB = 0) Then
'  WScript.Echo VbCrLf & "Created registry subkeys:" & VbCrLf & _
'   "HKEY_CURRENT_USER\" & g_strKeyPathA & VbCrLf & "HKEY_CURRENT_USER\" & _
'   g_strKeyPathB
  CreateSubKeys = True
Else
'  WScript.Echo "Unable to create registry subkeys."
  CreateSubKeys = False
End If

End Function

'******************************************************************************

Sub SetValues

'Local variables
strEntryNameA1 = "Flags"
strEntryNameA2 = "Version"
intValueA1 = 1
strValueA2 = "*"
strEntryNameB1 = "Blocked"
strEntryNameB2 = "Count"
strEntryNameB3 = "Type"
strEntryNameB4 = "Time"
intValueB1 = 4
intValueB2 = &Hdf
intValueB3 = 3
arrValueB4 = Array(&Hd4, &H07, &H07, &H00, &H04, &H00, &H1d, &H00, &H0c, _
 &H00, &H20, &H00, &H2b, &H00, &H80, &H00)

intReturnA1 = objReg.SetDWORDValue(HKEY_CURRENT_USER, g_strKeyPathA, _
 strEntryNameA1, intValueA1)
intReturnA2 = objReg.SetStringValue(HKEY_CURRENT_USER, g_strKeyPathA, _
 strEntryNameA2, strValueA2)
If (intReturnA1 = 0) And (intReturnA2 = 0) Then
'  WScript.Echo VbCrLf & "Added registry entries to:" & VbCrLf & _
'   "HKEY_CURRENT_USER\" & g_strKeyPathA & VbCrLf & _
'   "Entry: " & strEntryNameA1 & VbTab & "Value: " & intValueA1 & VbCrLf & _
'   "Entry: " & strEntryNameA2 & VbTab & "Value: " & strValueA2
Else
'  WScript.Echo VbCrLf & "ERROR: Unable to add registry entries to:" & _
'   VbCrLf & "HKEY_CURRENT_USER\" & g_strKeyPathA & "."
End If

intReturnB1 = objReg.SetDWORDValue(HKEY_CURRENT_USER, g_strKeyPathB, _
 strEntryNameB1, intValueB1)
intReturnB2 = objReg.SetDWORDValue(HKEY_CURRENT_USER, g_strKeyPathB, _
 strEntryNameB2, intValueB2)
intReturnB3 = objReg.SetDWORDValue(HKEY_CURRENT_USER, g_strKeyPathB, _
 strEntryNameB3, intValueB3)
intReturnB4 = objReg.SetBinaryValue(HKEY_CURRENT_USER, g_strKeyPathB, _
 strEntryNameB4, arrValueB4)
If (intReturnB1 = 0) And (intReturnB2 = 0) And (intReturnB3 = 0) _
 And (intReturnB4 = 0) Then
  For Each Value in arrValueB4
    strValueB4 = strValueB4 & Hex(Value) & " "
  Next
'  WScript.Echo VbCrLf & "Added registry entries to:" & VbCrLf & _
'   "HKEY_CURRENT_USER\" & g_strKeyPathA & VbCrLf & _
'   "Entry: " & strEntryNameB1 & VbTab & "Value: " & Hex(intValueB1) & _
'   VbCrLf & "Entry: " & strEntryNameB2 & VbTab & "Value: " & _
'   Hex(intValueB2) & VbCrLf & "Entry: " & strEntryNameB3 & VbTab & _
'   "Value: " & Hex(intValueB3) & VbCrLf & "Entry: " & strEntryNameB4 & _
'   VbTab & "Value: " & strValueB4
Else
'  WScript.Echo VbCrLf & "ERROR: Unable to add registry entries to:" & _
'   VbCrLf & "HKEY_CURRENT_USER\" & g_strKeyPathB & "."
End If

End Sub

MSのサイトを更に見てると複数のコンピューターに対してアドオンの無効を実行するサンプルもありました。
MS Technet:AddOn-wmi-multi.vbsで公開されています。