CreateUpdateDownloader 如何知道要下载哪些文件?
How does CreateUpdateDownloader know to download what files?
CreateUpdateDownloader
如何下载文件?我问是因为我的系统缺少 4 KB。
我通过在我的脚本中迭代更新 collection 获得了 4 个丢失的 KB 的标题。
当我将 collection 分配给 CreateUpdateDownloader
时,我在 C:\Windows\SoftwareDistribution\Download.
中只找到 1 KB
知道为什么它没有下载其他 3 KB 文件吗?是的,我现在只是想扫描和下载——尝试通过实际观看来了解它是如何工作的。我稍后会安装,因为我想调整其中的一些。
代码如下:
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()
必须使用Microsoft.Update.UpdateColl收集更新下载。
函数 CopyFromCache 允许下载更新的本地副本。
属性 DownloadURL 将允许您从 Internet 下载。
很有用iupdate object documentation
这是我的 "first" 编码方法。
前 5 个更新下载到 d:\updates 目录,并列出它们对应的 URL。
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 updatesToDownload = CreateObject("Microsoft.Update.UpdateColl")
Set downloader = session.CreateUpdateDownloader()
'For I = 0 to result.Updates.Count-1
For I = 0 to 5
Set update = result.Updates.Item(I)
updatesToDownload.Add(update)
Next
WScript.Echo vbCRLF & "Downloading updates..."
downloader.Updates = updatesToDownload
downloader.Download()
'For I = 0 to result.Updates.Count-1
for i=0 to 5
for each upd in downloader.Updates.Item(i).BundledUpdates
upd.CopyFromCache "d:\UPDATES", False
for each content in upd.DownloadContents
wscript.echo "url: " & content.DownloadURL
next
next
next
CreateUpdateDownloader
如何下载文件?我问是因为我的系统缺少 4 KB。
我通过在我的脚本中迭代更新 collection 获得了 4 个丢失的 KB 的标题。
当我将 collection 分配给 CreateUpdateDownloader
时,我在 C:\Windows\SoftwareDistribution\Download.
知道为什么它没有下载其他 3 KB 文件吗?是的,我现在只是想扫描和下载——尝试通过实际观看来了解它是如何工作的。我稍后会安装,因为我想调整其中的一些。
代码如下:
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()
必须使用Microsoft.Update.UpdateColl收集更新下载。 函数 CopyFromCache 允许下载更新的本地副本。 属性 DownloadURL 将允许您从 Internet 下载。 很有用iupdate object documentation
这是我的 "first" 编码方法。 前 5 个更新下载到 d:\updates 目录,并列出它们对应的 URL。
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 updatesToDownload = CreateObject("Microsoft.Update.UpdateColl")
Set downloader = session.CreateUpdateDownloader()
'For I = 0 to result.Updates.Count-1
For I = 0 to 5
Set update = result.Updates.Item(I)
updatesToDownload.Add(update)
Next
WScript.Echo vbCRLF & "Downloading updates..."
downloader.Updates = updatesToDownload
downloader.Download()
'For I = 0 to result.Updates.Count-1
for i=0 to 5
for each upd in downloader.Updates.Item(i).BundledUpdates
upd.CopyFromCache "d:\UPDATES", False
for each content in upd.DownloadContents
wscript.echo "url: " & content.DownloadURL
next
next
next