Export (0) Print
Expand All

AddOn-wmi.vbs

By The Scripting Guys, Microsoft Corporation

This script disables a specific Internet Explorer add-on by editing the registry using the WMI System Registry provider. 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.

Addon-wmi.vbs corresponds to AddOn.vbs, one of the scripts that ships with Application Compatibility Testing and Mitigation Guide for Windows XP Service Pack 2 and which are documented in the Appendix. You can download a Windows Installer (.msi) file that installs the Guide and its associated scripts from:

http://www.microsoft.com/downloads/details.aspx?FamilyId=9300BECF-2DEE-4772-ADD9-AD0EAF89C4A7&displaylang=en

To use the script, copy the code, paste it into Notepad, and then save the script as addon-wmi.vbs. To run the script, open a command prompt window to the directory of the script and type:

cscript addon-wmi.vbs

If the default script host on the computer is Cscript.exe, the initial "cscript" may be omitted.

Script Code



'******************************************************************************
'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.
'******************************************************************************

On Error Resume Next

'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\{06849E9F-C8D7-4D59-B87D-784B7D6BE0B3}"
g_strKeyPathB = "Software\Microsoft\Windows" & _
 "\CurrentVersion\Ext\Stats\{06849E9F-C8D7-4D59-B87D-784B7D6BE0B3}\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
Err.Clear

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

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



For online peer support, join The Official Scripting Guys Forum! To provide feedback or report bugs in sample scripts, please start a new discussion on the Discussions tab for this script.

Disclaimer

This sample script is not supported under any Microsoft standard support program or service. The sample script is provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft