Error 0x80244022 means that the update server HTTP service became temporarily unavailable (for whatever reason). See this MSKB article for a list of connectivity-related error codes.
To handle this error put it between an On Error Resume Next
and an On Error Goto 0
statement:
Set updateSession = CreateObject("Microsoft.Update.Session")
Set updateSearcher = updateSession.CreateupdateSearcher()
On Error Resume Next
Set searchResult = updateSearcher.Search("IsInstalled=0 and Type='Software'")
If Err Then
'add logging routine here
WScript.Quit 1
End If
On Error Goto 0
'more code here
Note that the above will indiscriminately terminate the script on any error that occurs when calling the Search
method. If you want to handle different errors in different ways, you could for instance put a Select
statement inside the conditional:
If Err Then
Select Case Err.Number
Case &h80244022
'quit immediately
WScript.Quit 1
Case &h8009033F
'wait some time and retry
WScript.Sleep 900000
Set searchResult = updateSearcher.Search(...)
Case &h...
'just log a message and continue
...
End Select
End If