Werbung: SecurityConsole.de verwaltet Ihre Computer mit Security Essentails aus der Cloud!
30 Tage kostenfrei testen und 20% Rabatt für Ihre Bestellung mit Promocode: WBF2685582
(Promocode gültig bis 31.12.2011)

Group:  English: Windows Server » microsoft.public.windows.server.update_services
Thread: WU API Question ... force full-file download

HTVi
TV Discussion Newsgroups

WU API Question ... force full-file download
AJR <AJR.2tixnm[ at ]DoNotSpam.com> 7/10/2007 9:03:34 PM
Hi

I created a VBscript which uses the Windows Update API
to automatically create an up-to-date patch kit.
The patch kit created contains the
patch binaries and a batch script to install them; the patch kit
can then be used on systems which are not yet online
(new systems being built and other offline systems .... etc)

To first order, the script works it downloads the patches
and it creates a batch file which can be used to install the patches.
However, I would like the script to always download the
full-file version of the patches rather than the delta version.

How can I do this ??


Thanks

Andy
romeroajr[ at ]yahoo.com

Here is the current version of the script: (may wrap)
REM ---------------------------------------------------------------------
REM
REM BuildPatchKit.vbs v1.0
REM Andy Romero
REM
REM This scripts intended purpose is to
REM collect the current set of applicable patches and
REM automatically write a script to install them.
REM This will help maintain O/S initial build kits
REM and offline patching kits
REM
REM Run this script on a dev VM with the following properties
REM - Windows firewall on (NO EXCEPTIONS)
REM - Your chosen **UNpatched** baseline
REM example: XP,SP-2,IE7,DotNET3.0
REM
REM ---------------------------------------------------------------------

Option explicit


REM User configurable settings ------------------------------------------

REM Output file in which to place patch installation command lines
dim sOutPutFile: sOutPutFile = "PatchInstallScriptBody.txt"

REM The dir path prefix of the dir which contain the patch binaries
dim sTargDirBase: sTargDirBase = "C:\BuildPatchKit\kit-"

REM The default patch installation command line parameters
dim sDefaultParams: sDefaultParams = "/quiet /norestart"



REM ----------------------------------------------------------------------

dim i: i=0
dim j: j=0
dim sTargDir
dim oFSO: set oFSO = CreateObject("Scripting.FileSystemObject")
dim objSearcher: set objSearcher = CreateObject("Microsoft.Update.Searcher")
dim updatesToDownload: set updatesToDownload = CreateObject("Microsoft.Update.UpdateColl")
dim updateSession: set updateSession = CreateObject("Microsoft.Update.Session")
dim downloader: set downloader = updateSession.CreateUpdateDownloader()
dim oWshShell: set oWshShell = WScript.CreateObject("WScript.Shell")
dim YesNoAnsOK: YesNoAnsOK = false
dim sYesNoAns

dim colUpdDnldContents
dim colBundUpdates
dim oTargDir
dim oTargDirFiles
dim oTargDirFile
dim oTargDirSubFolders
dim sParamInString
dim sPatchCmdLine

dim oStdIn: Set oStdIn = WScript.StdIn
dim oStdOut: Set oStdOut = WScript.StdOut
dim oOutPutFile: set oOutPutFile = oFSO.CreateTextFile(sOutPutFile, true)

REM The source of patch scan data (2=Microsoft) (1=local WSUS ??) (3=custom source .. ie offline)
objSearcher.ServerSelection = 2


Wscript.Echo "Checking with Microsoft for all applicable updates .... Please Wait ..."
dim objResults: Set objResults = objSearcher.Search("IsInstalled=0 and Type='Software'")
dim colUpdates: Set colUpdates = objResults.Updates


Wscript.Echo ""
Wscript.Echo "Total Number of Updates: " & colUpdates.Count


Wscript.Echo ""
Wscript.Echo "You will now have a chance to pick the updates you want"
For i = 0 to colUpdates.Count - 1
wscript.echo
wscript.echo
Wscript.Echo colUpdates.Item(i).Title & " " & colUpdates.Item(i).type & " " & colUpdates.Item(i).LastDeploymentChangeTime
wscript.echo


YesNoAnsOK = false
do while (YesNoAnsOK = false)
call oStdOut.write("DOWNLOAD THIS PACKAGE (y/n): ")
sYesNoAns = lcase(oStdIn.ReadLine)

if (sYesNoAns="y") then
updatesToDownload.Add(colUpdates.Item(i))
YesNoAnsOK = true
elseif (sYesNoAns="n") then
YesNoAnsOK = true
else
YesNoAnsOK = false
end if

loop



next

wscript.echo ""
wscript.echo "Downloading updates from Microsoft .... this can take awhile (1 min - 120 min)"
downloader.Updates = updatesToDownload
downloader.Download()

rem set colUpdDnldContents = colUpdates.Item(i).DownloadContents
rem wscript.echo "Count of Download Items in Update: " & colUpdDnldContents.count
rem for j = 0 to colUpdDnldContents.count - 1
rem wscript.echo "Download URL: " & colUpdDnldContents.Item(j).DownloadUrl
rem wscript.echo "Is Delta Content: " & colUpdDnldContents.Item(j).IsDeltaCompressedContent
rem next



wscript.echo ""
wscript.echo "Extracting updates from WU Cache and writing script .... Please Wait"
For i = 0 to colUpdates.Count - 1
sTargDir = sTargDirBase & i
if (colUpdates.Item(i).IsDownLoaded) then
oFSO.CreateFolder(sTargDir)
Wscript.Echo "Title: " & colUpdates.Item(i).Title & " " & colUpdates.Item(i).LastDeploymentChangeTime
set colBundUpdates = colUpdates.Item(i).BundledUpdates
wscript.echo "Bundle Count: " & colBundUpdates.count
for j = 0 to colBundUpdates.Count - 1
Wscript.Echo "Title: " & colBundUpdates.Item(j).Title

on error resume next
call colBundUpdates.Item(j).CopyFromCache(sTargDir, False)
wscript.echo "CopyFromCache Return Val: " & err.number
err.clear

REM get the file count of the target dir ... if its 1 then collect the patch in the
REM kit and test the params

Set oTargDir = oFSO.GetFolder(sTargDir)
set oTargDirFiles = oTargDir.files

Set oTargDirSubFolders = oTargDir.SubFolders


wscript.echo "FileCount: " & oTargDirFiles.count
wscript.echo "SubFolderCount: " & oTargDirSubFolders.count

REM Patch is a single file
if ( (oTargDirFiles.count=1) AND (oTargDirSubFolders.count = 0) ) then

For Each oTargDirFile in oTargDirFiles
sPatchCmdLine = sTargDir & "\" & oTargDirFile.name & " /?"
wscript.echo "Test Cmd Line: " & sPatchCmdLine
call oWshShell.Run(sPatchCmdLine, 1, true)
call oStdOut.write("Enter Params (default is " & sDefaultParams & ") : ")
sParamInString = oStdIn.ReadLine


call oOutPutFile.WriteLine("")
call oOutPutFile.WriteLine("REM ----------------------------------------------------------------------")
call oOutPutFile.WriteLine("[ at ]echo " & colUpdates.Item(i).Title & " " & colUpdates.Item(i).LastDeploymentChangeTime)
call oOutPutFile.WriteLine("REM ----------------------------------------------------------------------")
call oOutPutFile.WriteLine("REM DeltaAvail: " & colUpdates.Item(i).DeltaCompressedContentAvailable)
call oOutPutFile.WriteLine("REM DeltaPref: " & colUpdates.Item(i).DeltaCompressedContentPreferred)
call oOutPutFile.WriteLine("REM BundlCnt: " & colBundUpdates.count)
call oOutPutFile.WriteLine("")
call oOutPutFile.WriteLine("pushd .\kit-" & i)
if (sParamInString="") then
call oOutPutFile.WriteLine(oTargDirFile.name & " " & sDefaultParams)
else
call oOutPutFile.WriteLine(oTargDirFile.name & " " & sParamInString)
end if
call oOutPutFile.WriteLine("popd")
call oOutPutFile.WriteLine("")


Next


REM Patch contains an update subdir and update.exe
elseif (oFSO.FileExists(sTargDir & "\update\update.exe")) then

sPatchCmdLine = sTargDir & "\update\update.exe /?"
wscript.echo "Test Cmd Line: " & sPatchCmdLine
call oWshShell.Run(sPatchCmdLine, 1, true)
call oStdOut.write("Enter Params (default is " & sDefaultParams & ") : ")
sParamInString = oStdIn.ReadLine


call oOutPutFile.WriteLine("")
call oOutPutFile.WriteLine("REM ----------------------------------------------------------------------")
call oOutPutFile.WriteLine("[ at ]echo " & colUpdates.Item(i).Title & " " & colUpdates.Item(i).LastDeploymentChangeTime)
call oOutPutFile.WriteLine("REM ----------------------------------------------------------------------")
call oOutPutFile.WriteLine("REM DeltaAvail: " & colUpdates.Item(i).DeltaCompressedContentAvailable)
call oOutPutFile.WriteLine("REM DeltaPref: " & colUpdates.Item(i).DeltaCompressedContentPreferred)
call oOutPutFile.WriteLine("REM BundlCnt: " & colBundUpdates.count)
call oOutPutFile.WriteLine("")
call oOutPutFile.WriteLine("pushd .\kit-" & i & "\update")
if (sParamInString="") then
call oOutPutFile.WriteLine("update.exe " & sDefaultParams)
else
call oOutPutFile.WriteLine("update.exe " & sParamInString)
end if
call oOutPutFile.WriteLine("popd")
call oOutPutFile.WriteLine("")



else

call oOutPutFile.WriteLine("")
call oOutPutFile.WriteLine("REM ----------------------------------------------------------------------")
call oOutPutFile.WriteLine("[ at ]echo " & colUpdates.Item(i).Title & " " & colUpdates.Item(i).LastDeploymentChangeTime)
call oOutPutFile.WriteLine("REM ----------------------------------------------------------------------")
call oOutPutFile.WriteLine("REM DeltaAvail: " & colUpdates.Item(i).DeltaCompressedContentAvailable)
call oOutPutFile.WriteLine("REM DeltaPref: " & colUpdates.Item(i).DeltaCompressedContentPreferred)
call oOutPutFile.WriteLine("REM BundlCnt: " & colBundUpdates.count)
call oOutPutFile.WriteLine("")
call oOutPutFile.WriteLine("REM MANUAL PATCH CMD LINE CONFIGURATION NEEDED")
call oOutPutFile.WriteLine("REM " & sTargDir)
call oOutPutFile.WriteLine("")


end if


next
end if
next

oOutPutFile.close
wscript.echo "done" -- AJR ------------------------------------------------------------------------ AJR's Profile: http://forums.techarena.in/member.php?userid=27785 View this thread: http://forums.techarena.in/showthread.php?t=781010 http://forums.techarena.in

Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net
Suche nach Orten, Städten, Postleitzahlen, Vorwahlen, Kfz-Kennzeichen