How does CreateUpdateDownloader
download files? I ask because my system is missing 4 KBs.
I get the title of the 4 missing KBs from iterating through an update collection in my script.
When I assign that collection to a CreateUpdateDownloader
though, I only find 1 KB in C:\Windows\SoftwareDistribution\Download.
Any thoughts why it didn't download the other 3 KBs? Yes, I'm only looking to scan and download for right now -- trying to learn how this works by watching it in action. I'll get to install later as I want to tweak some of that.
The code follows:
Dim session : Set session = CreateObject("Microsoft.Update.Session")
Dim search : Set search = session.CreateUpdateSearcher()
WScript.Echo "Searching for updates..." & vbCrLF
Set result = search.Search("IsInstalled=0 AND Type='Software' AND IsHidden=0")
WScript.Echo "Missing KBs:"
For i = 0 To result.Updates.Count -1 'last item in the collection always seems to be some kind of gibberish null.
Set update = result.Updates.Item(i)
WScript.Echo i + 1 & "> " & update.Title
Next
If result.Updates.Count = 0 Then
WScript.Echo "There are no applicable updates."
End If
Set downloader = session.CreateUpdateDownloader()
downloader.Updates = result.Updates ' updatesToDownload
downloader.Download()
It must be used Microsoft.Update.UpdateColl to collect updates to download. Function CopyFromCache allows to download a local copy of update. Propertie DownloadURL will allow you to get download from Internet. It was very useful iupdate object documentation
This is my "first" approach to code. First 5 updates are downloaded to d:\updates directory and their corresponding URL are listed.