Jeg spurgte ham inde på det message board om hvad han havde af
erfaringer og fik et rigtig godt svar. Han pegede mig ind på denne
side:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wua_sdk/wua/searching__downloading__and_installing_updates.asp
Og så gav han mig et VB script, som selv søger, downloader og
installere opdateringer, som er baseret på overstående Microsoft
artikel:
****Update.vbs Start****
Set updateSession = CreateObject("Microsoft.Update.Session")
Set updateSearcher = updateSession.CreateupdateSearcher()
'WScript.Echo "Searching for updates..." & vbCRLF
Set searchResult = _
updateSearcher.Search("IsInstalled=0 and Type='Software'")
'WScript.Echo "List of applicable items on the machine:"
For I = 0 To searchResult.Updates.Count-1
Set update = searchResult.Updates.Item(I)
Next
If searchResult.Updates.Count = 0 Then
WScript.Echo "There are no applicable updates."
WScript.Quit
End If
Set updatesToDownload = CreateObject("Microsoft.Update.UpdateColl")
For I = 0 to searchResult.Updates.Count-1
Set update = searchResult.Updates.Item(I)
updatesToDownload.Add(update)
Next
'WScript.Echo vbCRLF & "Downloading updates..."
Set downloader = updateSession.CreateUpdateDownloader()
downloader.Updates = updatesToDownload
downloader.Download()
'WScript.Echo vbCRLF & "List of downloaded updates:"
For I = 0 To searchResult.Updates.Count-1
Set update = searchResult.Updates.Item(I)
Next
Set updatesToInstall = CreateObject("Microsoft.Update.UpdateColl")
For I = 0 To searchResult.Updates.Count-1
set update = searchResult.Updates.Item(I)
If update.IsDownloaded = true Then
updatesToInstall.Add(update)
End If
Next
'WScript.Echo vbCRLF & "Would you like to install updates now? (Y/N)"
'strInput = WScript.StdIn.Readline
'WScript.Echo
WScript.Echo "Installing updates..."
Set installer = updateSession.CreateUpdateInstaller()
installer.Updates = updatesToInstall
Set installationResult = installer.Install()
'Output results of install
'WScript.Echo "Installation Result: " & _
'installationResult.ResultCode
'WScript.Echo "Reboot Required: " & _
'installationResult.RebootRequired & vbCRLF
'WScript.Echo "Listing of updates installed " & _
'"and individual installation results:"
'For I = 0 to updatesToInstall.Count - 1
' 'WScript.Echo I + 1 & "> " & _
' updatesToInstall.Item(i).Title & _
' ": " & installationResult.GetUpdateResult(i).ResultCode
'Next
****Update.vbs slut****