Blocking XPSP2 from installing

G

Guest

I am trying to block the delivery of XPSP2 on multiple computers. Microsoft
technet has supplied a script template to use that creates a registry key
that prevents SP2 from being downloaded. I have two questions:

1) When I run the script on a compter, it says "H:\blockxpsp2-multi2.vbs(1 ,
16) Microsoft VBScript compilation error: Expected end of statement" It
doesn't seem to be entering anything new into the registry and XPSP2 is not
blocked.

2) There are defferent sections of the script and I'm not sure what part I
hould be using or if it is all neccessary.

Here is the entire script:(sorry it's so long)


Copyright (c) Microsoft Corporation 2004
' File: BlockXPSP2.vbs
' Contents: Remotely blocks or unblocks the delivery of
' Windows XP SP2 from Windows Update web site or via Automatic
' Updates.
' History: 8/20/2004 Peter Costantini Created
' Version: 1.0

On Error Resume Next
pause
'Define constants and global variables.
Const HKEY_LOCAL_MACHINE = &H80000002
Const FOR_READING = 1
strFilename = "hosts.csv"
strKeyPath = "Software\Policies\Microsoft\Windows\WindowsUpdate"
strEntryName = "DoNotAllowXPSP2"
dwValue = 1

'If text file exists, read hosts list 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
strHost = objFile.ReadLine
arrHost = Split(strHost, ",")
strComputer = arrHost(0)
strBlock = LCase(arrHost(1))
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
If strBlock = "b" Then
AddBlock
ElseIf strBlock = "u" Then
RemoveBlock
Else
WScript.Echo "Invalid value in input file for this" & _
"computer."
End If
Else
WScript.Echo "Unable to connect to WMI service on " & _
strComputer & "."
End If
Err.Clear
Loop
objFile.Close

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

Sub AddBlock

'Check whether WindowsUpdate subkey exists.
strParentPath = "SOFTWARE\Policies\Microsoft\Windows"
strTargetSubKey = "WindowsUpdate"
intCount = 0
intReturn1 = objReg.EnumKey(HKEY_LOCAL_MACHINE, _
strParentPath, arrSubKeys)
If intReturn1 = 0 Then
For Each strSubKey In arrSubKeys
If strSubKey = strTargetSubKey Then
intCount = 1
End If
Next
If intCount = 1 Then
SetValue
Else
WScript.Echo "Unable to find registry subkey " & _
strTargetSubKey & ". Creating ..."
intReturn2 = objReg.CreateKey(HKEY_LOCAL_MACHINE, _
strKeyPath)
If intReturn2 = 0 Then
SetValue
Else
WScript.Echo "ERROR: Unable to create registry " & _
"subkey "& strTargetSubKey & "."
End If
End If
Else
WScript.Echo "ERROR: Unable to find registry path " & _
strParentPath & "."
End If

End Sub

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

Sub SetValue

intReturn = objReg.SetDWORDValue(HKEY_LOCAL_MACHINE, _
strKeyPath, strEntryName, dwValue)
If intReturn = 0 Then
WScript.Echo "Added registry entry to block Windows XP " & _
"SP2 deployment via Windows Update or Automatic Update."
Else
WScript.Echo "ERROR: Unable to add registry entry to " & _
"block Windows XP SP2 deployment via Windows Update " & _
"or Automatic Update."
End If

End Sub

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

Sub RemoveBlock

intReturn = objReg.DeleteValue(HKEY_LOCAL_MACHINE, _
strKeyPath, strEntryName)
If intReturn = 0 Then
WScript.Echo "Deleted registry entry " & strEntryName & _
". Unblocked Windows XP SP2 deployment via Windows " & _
"Update or Automatic Update."
Else
WScript.Echo "Unable to delete registry entry " & _
strEntryName & ". Windows XP SP2 deployment via " & _
"Windows Update or Automatic Update is not blocked."
End If

End Sub
 
T

Torgeir Bakken \(MVP\)

xgrantp said:
I am trying to block the delivery of XPSP2 on multiple computers. Microsoft
technet has supplied a script template to use that creates a registry key
that prevents SP2 from being downloaded. I have two questions:

1) When I run the script on a compter, it says "H:\blockxpsp2-multi2.vbs(1 ,
16) Microsoft VBScript compilation error: Expected end of statement" It
doesn't seem to be entering anything new into the registry and XPSP2 is not
blocked.

2) There are defferent sections of the script and I'm not sure what part I
hould be using or if it is all neccessary.

Here is the entire script:(sorry it's so long)


Copyright (c) Microsoft Corporation 2004

The line above is uncommented, that is what is causing the error.

Remove the line, or add a ' in front, like this:

' Copyright (c) Microsoft Corporation 2004

' File: BlockXPSP2.vbs
' Contents: Remotely blocks or unblocks the delivery of
' Windows XP SP2 from Windows Update web site or via Automatic
' Updates.
' History: 8/20/2004 Peter Costantini Created
' Version: 1.0

[snip]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top