What I do is run Windows Updates from a script I got and modified from a Microsoft site, posted below. A backup batch file can shut down all the guests with Vboxmanage, back them up if desired, then run this VBS script to get and install updates, then reboot. To allow the host desktop to notify the user there are updates, Windows Update settings can be set to Notify before Download, because the script downloads them itself. The script seems to always pull the same updates that are marked "Important" in the desktop Windows Updates window, but not the optional ones, and it automatically accepts any EULAs.
This line in my batch .cmd file runs the script:
Code: Select all
cscript.exe drive:\path\to\windowsupdateauto.vbs
Code: Select all
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Set shell = WScript.CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
scriptpath = fso.getparentfoldername(wscript.scriptfullname) & "\"
reportfilename = scriptpath & "WindowsUpdateReport.txt"
Set updateSession = CreateObject("Microsoft.Update.Session")
updateSession.ClientApplicationID = "MSDN Sample Script"
Set updateSearcher = updateSession.CreateUpdateSearcher()
WScript.Echo "Searching for updates..." & vbCRLF
Set searchResult = _
updateSearcher.Search("IsInstalled=0 and Type='Software' and IsHidden=0 and BrowseOnly=0")
WScript.Echo "List of applicable items on the machine:"
For I = 0 To searchResult.Updates.Count-1
Set update = searchResult.Updates.Item(I)
WScript.Echo I + 1 & "> " & update.Title
Next
If searchResult.Updates.Count = 0 Then
WScript.Echo "There are no applicable updates."
WScript.Quit
End If
'wscript.quit
WScript.Echo vbCRLF & "Creating collection of updates to download:"
Set updatesToDownload = CreateObject("Microsoft.Update.UpdateColl")
For I = 0 to searchResult.Updates.Count-1
Set update = searchResult.Updates.Item(I)
addThisUpdate = false
If update.InstallationBehavior.CanRequestUserInput = true Then
WScript.Echo I + 1 & "> skipping: " & update.Title & _
" because it requires user input"
Else
If update.EulaAccepted = false Then
update.AcceptEula()
addThisUpdate = true
Else
addThisUpdate = true
End If
End If
If addThisUpdate = true Then
WScript.Echo I + 1 & "> adding: " & update.Title
updatesToDownload.Add(update)
End If
Next
If updatesToDownload.Count = 0 Then
WScript.Echo "All applicable updates were skipped."
WScript.Quit
End If
WScript.Echo vbCRLF & "Downloading updates..."
Set downloader = updateSession.CreateUpdateDownloader()
downloader.Updates = updatesToDownload
downloader.Download()
Set updatesToInstall = CreateObject("Microsoft.Update.UpdateColl")
rebootMayBeRequired = false
WScript.Echo vbCRLF & "Successfully downloaded updates:"
For I = 0 To searchResult.Updates.Count-1
set update = searchResult.Updates.Item(I)
If update.IsDownloaded = true Then
WScript.Echo I + 1 & "> " & update.Title
updatesToInstall.Add(update)
If update.InstallationBehavior.RebootBehavior > 0 Then
rebootMayBeRequired = true
End If
End If
Next
If updatesToInstall.Count = 0 Then
WScript.Echo "No updates were successfully downloaded."
WScript.Quit
End If
If rebootMayBeRequired = true Then
WScript.Echo vbCRLF & "These updates may require a reboot."
End If
WScript.Echo "Installing updates..."
Set installer = updateSession.CreateUpdateInstaller()
installer.Updates = updatesToInstall
Set installationResult = installer.Install()
'Output results of install
set resultfile = fso.opentextfile(reportfilename,forwriting,true)
resultfile.writeline "Listing of updates installed and results:"
For I = 0 to updatesToInstall.Count - 1
resultfile.writeline cstr(I + 1) & "> " & updatesToInstall.Item(I).Title & ": " & installationResult.GetUpdateResult(I).ResultCode
Next
resultfile.writeline "Windows Update Result: " & installationResult.ResultCode
resultfile.close
WScript.Echo "Reboot Required: " & installationResult.RebootRequired
Also see here: viewtopic.php?f=1&t=61861 for how to run a Vboxmanage on any guest or running guests without knowing ahead of time which guests exist or are running.