Re: different patching syntax



I've tried on some pc. If it encounter errors, it will pop up an error. I
don't have the function to capture error message. Eg u trying to patch a IE
hotfix and it does not depends on "-u -z"

However this saves u process time by clicking one by one. After u done with
this, u can use mbsa to scan what is missing. And then repatch if need to
for certain files. I understand some patch requires *dependency* on other
patches, but if u do it long run, your machines will be less dependent on
other patches as time goes.

=======================================================================
on error resume next

If Wscript.Arguments.Count <> 1 Then
Wscript.Echo "Syntax Error. Correct syntax is:"
Wscript.Echo
Wscript.Echo "cscript allfiles.vbs <directory path>"
Wscript.Echo "Eg : cscript allfiles.vbs c:\patches"
Wscript.Quit
End If

mypath = Wscript.Arguments(0)

set objshell = wscript.createobject("wscript.shell")
set objdict = createobject("scripting.dictionary")

set objfso = createobject("Scripting.filesystemobject")
set objfolder=objfso.getfolder(mypath)

'check whether folder exists

if not objfso.folderexists(mypath) then
wscript.echo mypath & " not found."
wscript.quit
end if


if mypath = "c:\" or mypath = "d:\" then
wscript.echo "Should not run anything from root path."
wscript.quit
end if


set colfiles=objfolder.files

'store all filenames into dictionary
i=0
For Each objFile in colfiles
objdict.add i, objfile.name
i = i+1
Next




wscript.echo "Total hotfix files to run : " & i & VbCrLf

c=1
for each objitem in objdict

'define standard syntax for microsoft hotfixes
'eg <hotfix.exe> /passive /norestart

syntax = "-u -z"


filenamex = mypath & "\" & objdict.item(objitem) & " " & syntax

'execute each files
wscript.echo "Executing file " & c & " : " & filenamex

objshell.run ("%comspec% /c " & filenamex) ,0,true


c=c+1
next

wscript.echo vbcrlf
wscript.echo "Please do a restart after patches."






"Jrex7" <Jrex7@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:92222F1B-4733-4282-BFEA-B1404A53479C@xxxxxxxxxxxxxxxx
> James,
>
> Is your script working now? Is this the whole script as shown on this
page.
> I want to be able to run the patches without rebooting.
> Do I need to make changes to the script or can I use it like it is now?
>
> Please repost your script.
>
> thank you.
>
> "James" wrote:
>
> > i just realised that when i use -q -z parameters, it seems to work for
*ALL
> > * kinds of hofixes even though i type KB890047.EXE /?, the parameters
> > options are /passive /norestart /etc
> >
> > Does anyone or MVP can confirm with Microsoft ?
> >
> > I can't check mine because all my machines are fully 100% patched, so
the
> > installation will stop and ignore and will not proceed to the end.
> >
> >
> >
> > "Al Dunbar [MS-MVP]" <alan-no-drub-spam@xxxxxxxxxxx> wrote in message
> > news:u1$XyPBNFHA.1948@xxxxxxxxxxxxxxxxxxxxxxx
> > >
> > > "James" <jkklim@xxxxxxxxxxx> wrote in message
> > > news:uSXGAaANFHA.4028@xxxxxxxxxxxxxxxxxxxxxxx
> > > > i've wrote a script that reads a directory that contains all patches
and
> > > run
> > > > it automatically. However i realise microsoft has 2 different syntax
for
> > > > patches. Eg from microsoft exe
> > > >
> > > > 823559.exe uses -q -z
> > > > KB890047.EXE uses /passive /norestart
> > > >
> > > > When my script runs, it runs the default " /passive /norestart",
thus
> > most
> > > > kbxxx files can be executed. However when it encounters 823559.exe,
it
> > > > cannot run " /passive /norestart", thus prompting a message which is
> > > > equivalent to 823559 /?
> > >
> > > If the syntax is completely consistent with respect to the filename
> > syntax,
> > > why not just test for the filename starting with "KB"?
> > >
> > > > I would like to write a error handling routine that when such
prompts
> > > 823559
> > > > /? appears, i can trap the error number (when i click the ok
button),
> > and
> > > my
> > > > script will change its default syntax to "-q -z"
> > > >
> > > > Here is a sample code i wrote.
> > > >
> > > > ===============================
> > > > 'define standard syntax for microsoft hotfixes
> > > > 'eg <hotfix.exe> /passive /norestart
> > > > syntax = "/passive /norestart"
> > > > filenamex = mypath & "\" & objdict.item(objitem) & " " & syntax
> > > >
> > > > 'execute each files
> > > > wscript.echo "Executing file " & c & " : " & filenamex
> > > >
> > > > objshell.run ("%comspec% /c " & filenamex) ,0,true
> > > >
> > > >
> > > > if err.number <> 0 then
> > > > wscript.echo "Script redoing this patch using another -u -z
> > parameters."
> > > > new_syntax = " -u -z"
> > > > filenamex = mypath & "\" & objdict.item(objitem) & " " &
new_syntax
> > > > objshell.run("%comspec% /c " & filenamex),0,true
> > > > err.clear
> > > > end if
> > > > ===============================
> > >
> > > I do not think that the err object will receive any error indicator
from
> > the
> > > program that was run. As far as the .run method goes, if the indicated
> > > executable was run, the result would be success, regardless whether it
> > > succeeded from your point of view.
> > >
> > > You *might* be able to trap a return code with:
> > >
> > > rc = objshell.run ( ("%comspec% /c " & filenamex) ,0,true )
> > >
> > > however, you would need to know for a certainty that this would ALWAYS
> > > return non-zero in the event of getting the wrong parameters. Even if
it
> > > worked in some cases, I wouldn't think it a safe bet in all cases.
> > >
> > > Another way to do this would be to trap the output from the
executable. If
> > > the length of the output is zero, it might be safe to assume that the
> > > executable ran successfully, otherwise you would then try with the
other
> > > parameters.
> > >
> > > You can trap the output by modifying the %comspec% line to redirect
the
> > > output, or using the .exec method instead.
> > >
> > > Alternately, you *could* just run the executable twice, once with each
> > style
> > > of parameters. You would then just need to feel confident you (or
would it
> > > be your users?) could ignore the apparent error messages that would be
> > > displayed.
> > >
> > > /Al
> > >
> > >
> >
> >
> >


.