Advertisement
Guest User

Windows Update Agent VBScript checker, outputs text file

a guest
Jul 11th, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Set UpdateSession = CreateObject("Microsoft.Update.Session")
  2. Set UpdateServiceManager = CreateObject("Microsoft.Update.ServiceManager")
  3. Set UpdateService = UpdateServiceManager.AddScanPackageService("Offline Sync Service", "C:\wsusscn2.cab", 1)
  4. ' UpdateService must use absolute path
  5. Set UpdateSearcher = UpdateSession.CreateUpdateSearcher()
  6.  
  7. WScript.Echo "Searching for updates..." & vbCRLF
  8.  
  9. UpdateSearcher.ServerSelection = 3 ' ssOthers
  10.  
  11. UpdateSearcher.ServiceID = UpdateService.ServiceID
  12.  
  13. Set SearchResult = UpdateSearcher.Search("IsInstalled=0")
  14.  
  15. Set Updates = SearchResult.Updates
  16.  
  17. If searchResult.Updates.Count = 0 Then
  18.     WScript.Echo "There are no applicable updates."
  19.     WScript.Quit
  20. End If
  21.  
  22. ' WScript.Echo "List of applicable items on the machine when using wssuscan.cab:" & vbCRLF
  23.  
  24. Set objFileToWrite = CreateObject("Scripting.FileSystemObject").OpenTextFile("update_missing.txt",8,true)
  25. objFileToWrite.WriteLine("==Start of Update missing list==")
  26. For I = 0 to searchResult.Updates.Count-1
  27.     Set update = searchResult.Updates.Item(I)
  28.     ' WScript.Echo I + 1 & "> " & update.Title
  29.     objFileToWrite.WriteLine(I + 1 & "> " & update.Title)
  30. Next
  31. objFileToWrite.WriteLine("==End of Update missing list==")
  32. objFileToWrite.Close
  33. Set objFileToWrite = Nothing
  34. WScript.Echo "There are " & searchResult.Updates.Count & " updates, compiled to update_missing.txt"
  35. WScript.Quit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement