timbrigham
asked on
VBS Windows Update script
I am writing a VBS script for use with MDT. This script is supposed to pull down and install all available windows updates for Windows XP clients. Occasionally I receive error 0x80240016, which if I understand correctly indicates that a reboot is necessary before a given update will install. My question is how can I handle this gracefully, without a reboot for every single update the requests one? As it stands my script errors out by throwing 0x80240016.
Based on my logging it looks like the code is stopping on the line 'Set installationResult = installer.Install()" line.
Based on my logging it looks like the code is stopping on the line 'Set installationResult = installer.Install()" line.
Function DoUpdate()
Set updateSession = CreateObject("Microsoft.Update.Session")
Set updateSearcher = updateSession.CreateupdateSearcher()
Set searchResult = updateSearcher.Search("IsInstalled=0 and Type='Software'")
Set updatesToDownload = CreateObject("Microsoft.Update.UpdateColl")
Set updatesToInstall = CreateObject("Microsoft.Update.UpdateColl")
For I = 0 to searchResult.Updates.Count-1
Set update = searchResult.Updates.Item(I)
updatesToDownload.Add(update)
Set downloader = updateSession.CreateUpdateDownloader()
downloader.Updates = updatesToDownload
downloader.Download()
updatesToDownload.Clear()
If update.IsDownloaded = true Then
updatesToInstall.Add(update)
Set installer = updateSession.CreateUpdateInstaller()
installer.Updates = updatesToInstall
Set installationResult = nothing
Set installationResult = installer.Install()
updatesToInstall.Clear()
If ( installationResult is nothing OR installationResult.ResultCode <> 2 OR installationResult.RebootRequired ) Then
oEnvironment.Item("SMSTSRebootRequested") = "true"
oEnvironment.Item("SMSTSRetryRequested") = "true"
If ContinueReboot( update.Title ) Then
' Reboots aren't generally allowed from standard Windows Updates
oLogging.CreateEntry "Immediate Reboot Allowed for " & update.Title, LogTypeInfo
Exit For
Else
oLogging.CreateEntry "Immediate Reboot denied for " & update.Title, LogTypeInfo
End If
End If
End If
Next
End Function
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Who's Dave ? :^)
Sorry, my bad....somewhere along the line I thought I saw that was your name....I apologise if I'm wrong...
ASKER
Thanks gentlemen. The examples given for the error handling were just the ticket.