找回密码
 加入
搜索
查看: 3289|回复: 3

[AU3基础] Microsoft.Update.Session 问题

[复制链接]
发表于 2010-9-26 10:45:09 | 显示全部楼层 |阅读模式
使用离线方法搜索补丁,用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")错误,小白问题,望高手解答~
发表于 2010-9-26 13:02:43 | 显示全部楼层
因为没有 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

评分

参与人数 1金钱 +25 收起 理由
afan + 25

查看全部评分

 楼主| 发表于 2010-9-26 16:54:52 | 显示全部楼层
$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
 楼主| 发表于 2010-9-26 16:58:01 | 显示全部楼层
我说的吗,忘记了wsusscan.cab是以前老的了,我下载的是wsusscn2.cab,呵呵,见笑了~
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-11-15 02:29 , Processed in 0.088682 second(s), 27 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表