Microsoft.Update.Session 问题
使用离线方法搜索补丁,用VB可以通过用AU3提示错误.VBS代码:
Set UpdateSession = CreateObject("Microsoft.Update.Session")
Set UpdateServiceManager = CreateObject("Microsoft.Update.ServiceManager")
Set UpdateService = UpdateServiceManager.AddScanPackageService("Offline Sync Service", "d:\wsusscn2.cab")
AU3代码:
$UpdateSession = ObjCreate("Microsoft.Update.Session")
$UpdateServiceManager = ObjCreate("Microsoft.Update.ServiceManager")
$UpdateService = $UpdateServiceManager.AddScanPackageService("Offline Sync Service", "d:\wsusscan.cab")
AU3显示:$UpdateService = $UpdateServiceManager.AddScanPackageService("Offline Sync Service", "d:\wsusscan.cab")错误,小白问题,望高手解答~ 因为没有 wsusscn2.cab,需要下载
wsusscn2.CAB 文件下载地址:
http://go.microsoft.com/fwlink/?LinkID=74689
$UpdateSession = ObjCreate("Microsoft.Update.Session")
$UpdateServiceManager = ObjCreate("Microsoft.Update.ServiceManager")
$UpdateService = $UpdateServiceManager.AddScanPackageService("Offline Sync Service", "c:\wsusscn2.cab")
$UpdateSearcher = $UpdateSession.CreateUpdateSearcher()
ConsoleWrite("Searching for updates..." & @CRLF)
$UpdateSearcher.ServerSelection = 3 ; ssOthers
$UpdateSearcher.ServiceID = $UpdateService.ServiceID
$SearchResult = $UpdateSearcher.Search("IsInstalled=0")
$Updates = $SearchResult.Updates
If $SearchResult.Updates.Count = 0 Then
ConsoleWrite("There are no applicable updates.")
EndIf
ConsoleWrite("List of applicable items on the machine when using wsusscn2.cab:" & @CRLF)
For $I = 0 To $SearchResult.Updates.Count - 1
$update = $SearchResult.Updates.Item($I)
ConsoleWrite($I + 1 & "> " & $update.Title)
Next $UpdateSession = ObjCreate("Microsoft.Update.Session")
$UpdateServiceManager = ObjCreate("Microsoft.Update.ServiceManager")
$UpdateService = $UpdateServiceManager.AddScanPackageService("Offline", "d:\wsusscan.cab")
$UpdateSearcher = $UpdateSession.CreateUpdateSearcher()
MsgBox(0,"提示","正在搜索升级!")
$UpdateSearcher.ServerSelection = 3
$UpdateSearcher.ServiceID = $UpdateService.ServiceID
$SearchResult = $UpdateSearcher.Search("IsInstalled=0")
$Updates = $SearchResult.Updates
If $searchResult.Updates.Count = 0 Then
MsgBox(0,"提示","没用搜索到升级!")
Exit
EndIf
For $I = 0 to $searchResult.Updates.Count-1
$update = $searchResult.Updates.Item($I)
MsgBox(0,$I + 1,$update.Title)
Next
我说的吗,忘记了wsusscan.cab是以前老的了,我下载的是wsusscn2.cab,呵呵,见笑了~
页:
[1]