yucatan Posted March 27, 2008 Share Posted March 27, 2008 #include <date.au3> $updateSession = ObjCreate("Microsoft.update.Session") $updateSearcher = $updateSession.CreateupdateSearcher() ConsoleWrite ("Searching for updates..." & @CRLF) $searchResult = $updateSearcher.Search("IsInstalled=0 and Type='Software'") ConsoleWrite ("List of applicable items on the machine:") For $I = 0 To $searchResult.Updates.Count-1 $update = $searchResult.Updates.Item($I) ConsoleWrite ($I + 1 & "> " & $update.Title & @CR) Next If $searchResult.Updates.Count = 0 Then ConsoleWrite ("There are no applicable updates.") Exit EndIf ConsoleWrite (@CRLF & "Creating collection of updates to download:") $updatesToDownload = ObjCreate("Microsoft.update.UpdateColl") For $I = 0 to $searchResult.Updates.Count-1 $update = $searchResult.Updates.Item($I) ConsoleWrite ($I + 1 & "> adding: " & $update.Title & @CR) $updatesToDownload.Add($update) Next ConsoleWrite (@CRLF & "Downloading updates...") $downloader = $updateSession.CreateUpdateDownloader() $downloader.Updates = $updatesToDownload $downloader.Download() ConsoleWrite ( @CRLF & "List of downloaded updates:") For $I = 0 To $searchResult.Updates.Count-1 $update = $searchResult.Updates.Item($I) If $update.IsDownloaded Then ConsoleWrite ($I + 1 & "> " & $update.Title & @CR) EndIf Next $updatesToInstall = ObjCreate("Microsoft.update.UpdateColl") ConsoleWrite ( @CRLF & "Creating collection of downloaded updates to install:" ) For $I = 0 To $searchResult.Updates.Count-1 $update = $searchResult.Updates.Item($I) If $update.IsDownloaded = 1 Then ConsoleWrite ($I + 1 & "> adding: " & $update.Title & @CR) $updatesToInstall.Add($update) EndIf Next ConsoleWrite (@CRLF & "Installing updates...") $installer = $updateSession.CreateUpdateInstaller() $installer.Updates = $updatesToInstall $installationResult = $installer.Install() ;Output results of install ConsoleWrite ("Installation Result: " & $installationResult.ResultCode ) ConsoleWrite ("Listing of updates installed " & "and individual installation results:" ) For $I = 0 to $updatesToInstall.Count - 1 ConsoleWrite ($I + 1 & "> " & $updatesToInstall.Item($I).Title & ": " & $installationResult.GetUpdateResult($I).ResultCode & @CR) Next why this dont work ? i get a error. Link to comment Share on other sites More sharing options...
monoceres Posted March 27, 2008 Share Posted March 27, 2008 Looks like more people than me experienced some server lag just now Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
DW1 Posted March 27, 2008 Share Posted March 27, 2008 Looks like more people than me experienced some server lag just now I hope thats what that is.... man thats a lot of duplicate posts. AutoIt3 Online Help Link to comment Share on other sites More sharing options...
yucatan Posted March 27, 2008 Author Share Posted March 27, 2008 huh..?? Link to comment Share on other sites More sharing options...
weaponx Posted March 27, 2008 Share Posted March 27, 2008 huh..??What don't you get? You posted the same topic 15 times. See page 2 in General Help & Support. Link to comment Share on other sites More sharing options...
DW1 Posted March 27, 2008 Share Posted March 27, 2008 Replace If $update.IsDownloaded = 1 ThenoÝ÷ Ùh«¢+Ù%ÀÌØíÕÁѹ%ͽݹ±½ôQÉÕQ¡¸ AutoIt3 Online Help Link to comment Share on other sites More sharing options...
DW1 Posted March 27, 2008 Share Posted March 27, 2008 (edited) Works for me now: expandcollapse popup#include <date.au3> $updateSession = ObjCreate("Microsoft.update.Session") $updateSearcher = $updateSession.CreateupdateSearcher() ConsoleWrite("Searching for updates..." & @CRLF) $searchResult = $updateSearcher.Search("IsInstalled=0 and Type='Software'") ConsoleWrite("List of applicable items on the machine:") For $I = 0 To $searchResult.Updates.Count - 1 $update = $searchResult.Updates.Item($I) ConsoleWrite($I + 1 & "> " & $update.Title & @CR) Next If $searchResult.Updates.Count = 0 Then ConsoleWrite("There are no applicable updates.") Exit EndIf ConsoleWrite(@CRLF & "Creating collection of updates to download:") $updatesToDownload = ObjCreate("Microsoft.update.UpdateColl") For $I = 0 To $searchResult.Updates.Count - 1 $update = $searchResult.Updates.Item($I) ConsoleWrite($I + 1 & "> adding: " & $update.Title & @CR) $updatesToDownload.Add($update) Next ConsoleWrite(@CRLF & "Downloading updates...") $downloader = $updateSession.CreateUpdateDownloader() $downloader.Updates = $updatesToDownload $downloader.Download() ConsoleWrite(@CRLF & "List of downloaded updates:") For $I = 0 To $searchResult.Updates.Count - 1 $update = $searchResult.Updates.Item($I) If $update.IsDownloaded Then ConsoleWrite($I + 1 & "> " & $update.Title & @CR) EndIf Next $updatesToInstall = ObjCreate("Microsoft.update.UpdateColl") ConsoleWrite(@CRLF & "Creating collection of downloaded updates to install:") For $I = 0 To $searchResult.Updates.Count - 1 $update = $searchResult.Updates.Item($I) If $update.IsDownloaded = True Then ConsoleWrite($I + 1 & "> adding: " & $update.Title & @CR) $updatesToInstall.Add($update) EndIf Next ConsoleWrite(@CRLF & "Installing updates...") $installer = $updateSession.CreateUpdateInstaller() $installer.Updates = $updatesToInstall If $updatesToInstall.Count > 0 Then $installationResult = $installer.Install() ;Output results of install ConsoleWrite("Installation Result: " & $installationResult.ResultCode) ConsoleWrite("Listing of updates installed " & "and individual installation results:") For $I = 0 To $updatesToInstall.Count - 1 ConsoleWrite($I + 1 & "> " & $updatesToInstall.Item($I).Title & ": " & $installationResult.GetUpdateResult($I).ResultCode & @CR) Next Else ConsoleWrite(@CRLF & "Nothing to install" & @CRLF) EndIf EDIT: You were not adding to the $updatestoinstall. You would have gotten this same error (even with the fix of 'True' instead of '1') if there were no updates to install. This simple count check pre-install will take care of that issue as well. Edited March 27, 2008 by danwilli AutoIt3 Online Help Link to comment Share on other sites More sharing options...
Zedna Posted March 27, 2008 Share Posted March 27, 2008 Sometimes when forum server lags at time of saving my post I created duplicated posts too. But everytime I immediatelly delete my second duplicate post and I have never accidentaly created more than two or three posts. Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now