AddOn-wmi-multi.vbs
By The Scripting Guys, Microsoft Corporation
This script runs against multiple computers to disable a specific Internet Explorer add-on. It makes this change 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-multi.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:
Input for this script comes from a text file, addon-hosts.txt, which contains the names of computers against which the script will run.
Each line of the input file must contain the name of a computer. Each computer must be accessible on the network and the credentials under which the script is run must have administrative privileges on it. For example:
client1
client2
server1
server2
Be sure there is no line break after the final line, as this will be interpreted by the script as an empty string.
To use the script, copy the code, paste it into Notepad, and then save the script as addon-wmi-multi.vbs. Then create a text file with the name of a computer on each line, as described above, and save it as addon-hosts.txt in the same directory as the script. To run the script, open a command prompt window to the directory of the script and type:
cscript addon-wmi-multi.vbs
If the default script host on the computer is Cscript.exe, the initial "cscript" may be omitted.
Script Code
'******************************************************************************
'AddOn-wmi-multi.vbs
'Author: Peter Costantini, the Microsoft Scripting Guys
'Date: 8/25/04
'Revision 1.0
'This script can be run against multiple computers to remotely
'disable a specific Internet Explorer add-on by editing the registry.
'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.
'The multiple computers must be specified in a text file,
'addon-hosts.txt, in the same directory as the script.
'Each line of addon-hosts.txt must contain a computer name.
'Do not add a newline to the end of the last line.
'Example:
'client1
'client2
'server1
'server2
'******************************************************************************
On Error Resume Next
'Global constants and variables
Const FOR_READING = 1
Const HKEY_CURRENT_USER = &H80000001
strFilename = "addon-hosts.txt"
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"
'If text file exists, read list of hosts and operation for each.
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists(strFilename) Then
Set objFile = objFSO.OpenTextFile(strFilename, FOR_READING)
Else
WScript.Echo "Input file " & strFilename & " not found."
WScript.Quit
End If
Do Until objFile.AtEndOfStream
'Get name of computer.
strComputer = objFile.ReadLine
Wscript.Echo VbCrLf & strComputer
Wscript.Echo String(Len(strComputer), "-")
'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 "ERROR: Unable to connect to WMI StdRegProv on " & _
strComputer & "."
WScript.Echo " Error Number: " & Err.Number
WScript.Echo " Source: " & Err.Source
WScript.Echo " Description: " & Err.Description
End If
Err.Clear
Loop
objFile.Close
'******************************************************************************
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.