Advertisement
Ibra86

HideOptionalUpdates.vbs

Nov 19th, 2019
998
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Dim updateSession, updateSearcher
  2. Set updateSession = CreateObject("Microsoft.Update.Session")
  3. Set updateSearcher = updateSession.CreateUpdateSearcher()
  4. strSearchCriteria = "IsInstalled=0 and DeploymentAction='OptionalInstallation'"
  5.  
  6. Wscript.Stdout.Write "Checking for updates..." & vbCRLF
  7. Dim searchResult
  8. Set searchResult = updateSearcher.Search(strSearchCriteria)
  9.  
  10. If IsEmpty(searchResult) Then
  11.     WScript.Echo "The search did not return any updates."
  12.     WScript.Quit(5)
  13. End If
  14.  
  15. WScript.Echo "Updates found: " & CStr(searchResult.Updates.Count) & vbCRLF
  16. Dim update, KB, index
  17. For index = 0 To searchResult.Updates.Count - 1
  18.     Set update = searchResult.Updates.Item(index)
  19.     If update.IsHidden = False Then
  20.       WScript."Hiding update: " & update.Title
  21.       update.IsHidden = True
  22.     Else
  23.       WScript."Already hidden: " & update.Title
  24.     End If          
  25. Next
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement