VATERNL Posted July 10, 2010 Share Posted July 10, 2010 I am currently struggling to find information on howto install Windows 7 Update *.cab files.In the past I used the below pasted simple script to install Windows XP \ 2003 Hotfix collections that were not yet integrated in the base-image.Can anyone enlighten me with a working solution ?dir "\\windows_xp\updates\windowsxp_x86\*" /b > %temp%\windowsxp_x86_glb.logfor /f "tokens=*" %%a in (%temp%\windows7_x64_glb.log) do "\\windows_xp\updates\windowsxp_x86\%%a" /quiet /norestart Link to comment Share on other sites More sharing options...
IcemanND Posted July 11, 2010 Share Posted July 11, 2010 Pulls missing updates from Microsoft (or WSUS if configured for it) and installs:Set updateSession = CreateObject("Microsoft.Update.Session")Set updateSearcher = updateSession.CreateupdateSearcher()WScript.Echo "Searching for updates..." & vbCRLFSet 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) WScript.Echo I + 1 & "> " & update.TitleNextIf searchResult.Updates.Count = 0 Then WScript.Echo "There are no applicable updates." WScript.QuitEnd IfWScript.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) WScript.Echo I + 1 & "> adding: " & update.Title updatesToDownload.Add(update)NextWScript.Echo vbCRLF & "Downloading updates..."Set downloader = updateSession.CreateUpdateDownloader() downloader.Updates = updatesToDownloaddownloader.Download()WScript.Echo vbCRLF & "List of downloaded updates:"For I = 0 To searchResult.Updates.Count-1 Set update = searchResult.Updates.Item(I) If update.IsDownloaded Then WScript.Echo I + 1 & "> " & update.Title End IfNextSet updatesToInstall = CreateObject("Microsoft.Update.UpdateColl")WScript.Echo vbCRLF & _"Creating collection of downloaded updates to install:" For I = 0 To searchResult.Updates.Count-1 set update = searchResult.Updates.Item(I) If update.IsDownloaded = true Then WScript.Echo I + 1 & "> adding: " & update.Title updatesToInstall.Add(update) End IfNextWScript.Echo "Installing updates..."Set installer = updateSession.CreateUpdateInstaller()installer.Updates = updatesToInstallSet installationResult = installer.Install()'Output results of installWScript.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 Link to comment Share on other sites More sharing options...
maxXPsoft Posted July 11, 2010 Share Posted July 11, 2010 Dism /image:D:\zMountDir /Add-Package /PackagePath:"D:\zMountDir\Sandbox\Windows6.1-KB958644-x86.cab" /LogPath:D:\Se7en_UA\Logs\HOTFIXES.log Link to comment Share on other sites More sharing options...
VATERNL Posted July 11, 2010 Author Share Posted July 11, 2010 Thank you for the provided solutions.However:In my environment I want to control which updates are installed without making use of WSUS.Slipstreaming into the image is fine, but does not help me to maintain running machines.I am looking for information on how to install a set of tested windows 2008 updates.In the past that was easy -> see script bit. Although the script of IcemanND is very cool, it is not 100% what I need.I assume I only need to know what kind of switches I can use to silently install windows 2008 *.cab files.( or whatever method I can use ). Link to comment Share on other sites More sharing options...
IcemanND Posted July 11, 2010 Share Posted July 11, 2010 Put your list of approved updates in an array or dictionary object, then modify the following section to see if the needed update is in array or dictionary object. If it is let it be added to the updatesToDownload object, if it is not then skip it. Only need to maintain a list of updates then don't have to download and maintain a folder somewhere full of updates to install. Or you could do the inverse and only have a list of updates you do not want installed.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) WScript.Echo I + 1 & "> adding: " & update.Title updatesToDownload.Add(update)Next Link to comment Share on other sites More sharing options...
VATERNL Posted July 11, 2010 Author Share Posted July 11, 2010 (edited) Thx for the clever update IcemanND...I never thought of that option.( I assume I am still too much focused on the very simple *.cmd approach ).I like the part where we do not have to maintain an install-repository.Saves me some space;)Will let you know how this works out. Edited July 11, 2010 by VATERNL Link to comment Share on other sites More sharing options...
IcemanND Posted July 12, 2010 Share Posted July 12, 2010 Place a text file in the same folder as the script, the text file should only contain the numberical portion of the KB article number, one number per line.WARNING: UntestedConst ForReading = 1Set objSearcher = CreateObject("Microsoft.Update.Searcher")Set DeniedUpdates = CreateObject("Scripting.Dictionary")set objFSO = CreateObject("Scripting.FileSystemObject")DeniedUpdates.CompareMode = VBBinaryCompareWscript.echo "Getting list of approved updates..." & VBCRLFset objFile = objFSO.OpenTextFile("approved.txt", ForReading)do until objFile.AtEndofStream fileLine = objFile.ReadLine if trim(fileLine)<> "" then ApprovedUpdates.add fileLine, fileLineloopobjFile.CloseWscript.echo "Getting list of denied updates..." & vbcrlfset objFile = objFSO.OpenTextFile("denied.txt", ForReading)do until objFile.AtEndofStream fileLine = objFile.ReadLine if trim(fileLine)<> "" then DeniedUpdates.add fileLine, fileLineloopobjFile.CloseWScript.Echo "Searching for updates..." & vbCRLFSet Set objResults = objSearcher.Search("IsInstalled=0 and Type='Software'")Set colUpdates = objResults.Updatesif colUpdates.count = 0 then Wscript.echo "No applicable updates to install." wscript.quitend ifWScript.Echo vbCRLF & "Creating collection of updates to download:"Set updatesToDownload = CreateObject("Microsoft.Update.UpdateColl")For i = 0 to colUpdates.Count - 1 Wscript.Echo "Title: " & colUpdates.Item(i).Title Wscript.Echo "KB article: " & strArticle For Each strArticle in colUpdates.Item(i).KBArticleIDs if not DeniedUpdates.Exists(strArticle) then Wscript.Echo "Added to download list" updatesToDownload.Add(update) else Wscript.Echo "Update not added found on Denied List" end if NextNextWScript.Echo vbCRLF & "Downloading updates..."Set downloader = objSearcher.CreateUpdateDownloader() downloader.Updates = updatesToDownloaddownloader.Download()WScript.Echo vbCRLF & "List of downloaded updates:"For I = 0 To searchResult.Updates.Count-1 Set update = searchResult.Updates.Item(I) If update.IsDownloaded Then WScript.Echo I + 1 & "> " & update.Title End IfNextWScript.Echo "Installing updates..."For I = 0 To searchResult.Updates.Count-1 set update = searchResult.Updates.Item(I) If update.IsDownloaded = true Then WScript.Echo I + 1 & "> adding: " & update.Title Set updatesToInstall = CreateObject("Microsoft.Update.UpdateColl") updatesToInstall.Add(update) 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 End IfNext Link to comment Share on other sites More sharing options...
hs2n Posted December 14, 2010 Share Posted December 14, 2010 You can do about the same without much programming, using WuInstall (http://www.wuinstall.com) and the /matchfile or /nomatchfile option.WuInstall uses basically the same API, but with many options, including getting a list of approved update from a file. 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