(view source code of disablelanguagepackupdates.vbs as plain text)
Option Explicit
Dim i, intCount, intSkipped
Dim objRE, objSearchResult, objWUpdate, objWUSearcher, objWUSession
Dim strException
strException = Null
With WScript.Arguments
If .Unnamed.Count > 0 Then Syntax
If .Named.Count > 1 Then Syntax
If .Named.Count = 1 Then
If .Named.Exists( "X" ) Then
strException = .Named.Item( "X" )
Else
Syntax
End If
End If
End With
Set objWUSession = CreateObject( "Microsoft.Update.Session" )
Set objWUSearcher = objWUSession.CreateUpdateSearcher( )
objWUSearcher.Online = False
If Not IsNull( strException ) Then
Set objRE = New RegExp
objRE.Global = True
objRE.IgnoreCase = True
objRE.Pattern = strException
End If
intCount = 0
intSkipped = 0
WScript.Echo( "Searching..." )
Set objSearchResult = objWUSearcher.Search( "IsHidden=0 And IsInstalled=0" )
For i = 0 To objSearchResult.Updates.Count - 1
Set objWUpdate = objSearchResult.Updates.Item(i)
If InStr( objWUpdate.Title, "Language Pack" ) > 0 Then
If IsNull( strException ) Then
WScript.Echo "Hiding " & objWUpdate.Title
objWUpdate.IsHidden = 1
intCount = intCount + 1
Else
If objRE.Test( objWUpdate.Title ) Then
WScript.Echo "Skipping " & objWUpdate.Title
intSkipped = intSkipped + 1
Else
WScript.Echo "Hiding " & objWUpdate.Title
objWUpdate.IsHidden = 1
intCount = intCount + 1
End If
End If
End If
Set objWUpdate = Nothing
Next
Set objSearchResult = Nothing
If Not IsNull( strException ) Then Set objRE = Nothing
Set objWUSearcher = Nothing
Set objWUSession = Nothing
Select Case intCount
Case 0:
WScript.Echo vbCrLf & "All optional Language Pack updates were either" _
& vbCrLf & "installed or hidden already, no change required"
Case 1:
WScript.Echo vbCrLf & "Hidden 1 optional Language Pack update"
Case Else:
WScript.Echo vbCrLf & "Hidden " & intCount & " optional Language Pack updates"
End Select
If intSkipped = 1 Then
WScript.Echo vbCrLf & "Skipped l Language Pack update"
ElseIf intSkipped > 1 Then
WScript.Echo vbCrLf & "Skipped " & intSkipped & " Language Pack updates"
End If
WScript.Quit intCount
Sub Syntax
Dim strMsg
strMsg = vbCrLf _
& "DisableLanguagePackUpdates.vbs, version 1.00" _
& vbCrLf _
& "Hide all Language Pack updates in Windows Update" _
& vbCrLf & vbCrLf _
& "Usage: DisableSilverlightUpdates.vbs /X:pattern" _
& vbCrLf & vbCrLf _
& "Where: /X:pattern specifies the eXceptions, i.e. the updates NOT to be" _
& vbCrLf _
& " hidden, as a regular expression pattern to test against" _
& vbCrLf _
& " the Language Pack title (e.g. /X:Czech)" _
& vbCrLf & vbCrLf _
& "Notes: Even if you do not wish to install Language Packs, Windows Update" _
& vbCrLf _
& " will offer 33 Language Packs as optional update. You can hide each" _
& vbCrLf _
& " of these manually, but why not let this script automate that for you?" _
& vbCrLf _
& " Based on a script written in JScript by Tony Marques" _
& vbCrLf _
& " (https://superuser.com/a/1009947)" _
& vbCrLf _
& " This script's return code is the number of Language Pack updates" _
& vbCrLf _
& " hidden by this script, or -1 in case of command line errors." _
& vbCrLf & vbCrLf _
& "Written by Rob van der Woude" _
& vbCrLf _
& "http://www.robvanderwoude.com"
WScript.Echo strMsg
WScript.Quit -1
End Sub
page last modified: 2024-04-16; loaded in 0.0068 seconds