Skip to content

Instantly share code, notes, and snippets.

@florianbeisel
Last active December 30, 2015 08:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save florianbeisel/7805795 to your computer and use it in GitHub Desktop.
Save florianbeisel/7805795 to your computer and use it in GitHub Desktop.
Lists installed Updates.
Dim updateSession, updateSearcher
Set updateSession = CreateObject("Microsoft.Update.Session")
Set updateSearcher = updateSession.CreateUpdateSearcher()
Wscript.Stdout.Write "Searching for pending updates..."
Dim searchResult
Set searchResult = updateSearcher.Search("IsInstalled=0")
Dim update, kbArticleId, index, index2
WScript.Echo CStr(searchResult.Updates.Count) & " found."
For index = 0 To searchResult.Updates.Count - 1
Set update = searchResult.Updates.Item(index)
WScript.Echo update.Identity.UpdateID & ": " & update.Title
Next
If Wscript.Arguments.Count = 0 Then
WScript.Echo "Syntax: HideWindowsUpdate.vbs [Hotfix Article ID]" & vbCRLF & _
"Examples:" & vbCRLF & _
" - Hide KB940157: HideWindowsUpdate.vbs 940157"
WScript.Quit 1
End If
Dim hotfixId
hotfixId = WScript.Arguments(0)
Dim updateSession, updateSearcher
Set updateSession = CreateObject("Microsoft.Update.Session")
Set updateSearcher = updateSession.CreateUpdateSearcher()
Wscript.Stdout.Write "Searching for pending updates..."
Dim searchResult
Set searchResult = updateSearcher.Search("IsInstalled=0")
Dim update, kbArticleId, index, index2
WScript.Echo CStr(searchResult.Updates.Count) & " found."
For index = 0 To searchResult.Updates.Count - 1
Set update = searchResult.Updates.Item(index)
For index2 = 0 To update.KBArticleIDs.Count - 1
kbArticleId = update.KBArticleIDs(index2)
If kbArticleId = hotfixId Then
WScript.Echo "Hiding update: " & update.Title
update.IsHidden = True
End If
Next
Next
If Wscript.Arguments.Count = 0 Then
WScript.Echo "Syntax: HideWindowsUpdate.vbs [Hotfix Article ID]" & vbCRLF & _
"Examples:" & vbCRLF & _
" - Hide KB940157: HideWindowsUpdate.vbs 940157"
WScript.Quit 1
End If
Dim hotfixId
hotfixId = WScript.Arguments(0)
Dim updateSession, updateSearcher
Set updateSession = CreateObject("Microsoft.Update.Session")
Set updateSearcher = updateSession.CreateUpdateSearcher()
Wscript.Stdout.Write "Searching for pending updates..."
Dim searchResult
Set searchResult = updateSearcher.Search("IsInstalled=0")
Dim update, kbArticleId, index, index2
WScript.Echo CStr(searchResult.Updates.Count) & " found."
For index = 0 To searchResult.Updates.Count - 1
Set update = searchResult.Updates.Item(index)
For index2 = 0 To update.KBArticleIDs.Count - 1
kbArticleId = update.KBArticleIDs(index2)
If kbArticleId = hotfixId Then
WScript.Echo "Hiding update: " & update.Title
update.IsHidden = True
End If
Next
Next
If Wscript.Arguments.Count = 0 Then
WScript.Echo "Syntax: HideWindowsUpdateById.vbs [Update ID]" & vbCRLF & _
"Examples:" & vbCRLF & _
" - Hide KB940157: HideWindowsUpdateById.vbs 2ba85467-deaf-44a1-a035-697742efab0f"
WScript.Quit 1
End If
Dim updateId
updateId = WScript.Arguments(0)
Dim updateSession, updateSearcher
Set updateSession = CreateObject("Microsoft.Update.Session")
Set updateSearcher = updateSession.CreateUpdateSearcher()
Wscript.Stdout.Write "Searching for pending updates..."
Dim searchResult
Set searchResult = updateSearcher.Search("UpdateID = '" & updateId & "'")
Dim update, index
WScript.Echo CStr(searchResult.Updates.Count) & " found."
For index = 0 To searchResult.Updates.Count - 1
Set update = searchResult.Updates.Item(index)
WScript.Echo "Hiding update: " & update.Title
update.IsHidden = True
Next
@florianbeisel
Copy link
Author

Lists installed Update in the following form:

07609d43-d518-4e77-856e-d1b316d1b8a8         MSXML 6.0 RTM Sicherheitsupdate (925673)
4fdb9ee1-391c-411c-85d9-eda28eaeb00a         Update für Microsoft Visual Studio 2010 Service Pack 1 Web Platform Tools (KB2548139)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment