我在MSDN官方网站上找到了此VBScript,以使用wsusscn2.cab文件(https://msdn.microsoft.com/en-us/library/windows/desktop/aa387290(v=vs.85).aspx)脱机检查更新。这是给出的代码:
Set UpdateSession = CreateObject("Microsoft.Update.Session")
Set UpdateServiceManager = CreateObject("Microsoft.Update.ServiceManager")
Set UpdateService = UpdateServiceManager.AddScanPackageService("Offline Sync Service", "C:\wsusscn2.cab", 1)
Set UpdateSearcher = UpdateSession.CreateUpdateSearcher()
WScript.Echo "Searching for updates..." & vbCRLF
UpdateSearcher.ServerSelection = 3
UpdateSearcher.ServiceID = UpdateService.ServiceID
Set SearchResult = UpdateSearcher.Search("IsInstalled=0")
Set Updates = SearchResult.Updates
If searchResult.Updates.Count = 0 Then
WScript.Echo "There are no applicable updates."
WScript.Quit
End If
WScript.Echo "List of applicable items on the machine when using wssuscan.cab:" & vbCRLF
For I = 0 to searchResult.Updates.Count-1
Set update = searchResult.Updates.Item(I)
WScript.Echo I + 1 & "> " & update.Title
Next
WScript.Quit
在执行代码时,在第12行出现错误消息“系统找不到指定的文件”。第12行是
Set SearchResult = UpdateSearcher.Search("IsInstalled=0")
该脚本与wsusscn2.cab文件一起放置在C驱动器中。任何帮助将不胜感激。
最佳答案
Windows Update有问题,这不是VBScript问题:
https://support.microsoft.com/en-us/help/4027322/windows-update-troubleshooter
关于vbscript - 使用UpdateSearcher.Search时出现错误80070002,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/50819875/