Page 1 of 2 12>
Topic Options
#108840 - 2003-11-25 12:05 PM problem installing multiple patches at same time
zigi Offline
Fresh Scripter

Registered: 2003-09-04
Posts: 27
Hello,

I have problems to install multiple microsoft patches at the same time. see code example below:

Code:
 
$PatchBat = "\\Logonserver\Patches"
....

Run $PatchBat + "Windows2000-KB823182-x86-DEU.exe -u -z"
Run $PatchBat + "Windows2000-KB825119-x86-DEU.exe -u -z"
Run $PatchBat + "Windows2000-KB826232-x86-DEU.exe /passive /norestart"
Run $PatchBat + "IE6SP1q824145.exe /q:a /r:n"
....



When I start the kixscript with a logonbat-file all run-commands are startet parallel. That causes errors and the patches won't be installed correctly.

Is there a command like "wait with starting second run-command until first run-command has finished sucessfully"?

i would be very greatful for any help.
thanks

zigi

Top
#108841 - 2003-11-25 12:16 PM Re: problem installing multiple patches at same time
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6343
Loc: Stuttgart, Germany
No,

there is no wait option for KiX' run command.
You might want to go with SHELL command instead which waits for completion

hth
_________________________



Top
#108842 - 2003-11-25 01:08 PM Re: problem installing multiple patches at same time
zigi Offline
Fresh Scripter

Registered: 2003-09-04
Posts: 27
great.
thank you.
the shell-command is the solution.


Top
#108843 - 2003-11-25 01:23 PM Re: problem installing multiple patches at same time
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
Assuming only win2k
place all win2k hotfixes in a single folder on a server share ($setup+'\Win2k_Hotfixes')

requires ArrEnumkey(), ArrEnumDir() UDFs

Code:

;************************************ W2K HotFix Updates *****************************************
if @ras=0
$arrkey = arrEnumKey('HKLM\SOFTWARE\Microsoft\Updates\Windows 2000\SP5')
$arrdir = arrEnumDir($setup+'\Win2k_Hotfixes','*.exe',1)
$reboot = 0
for each $dir in $arrdir
$installed = 0
$parsed = split($dir,'-')[1]
for each $key in $arrkey
if $key = $parsed $installed = 1 endif
next
if not $installed
$=sendmessage(@wksta,"A CRTICAL upgrade is now starting. Your computer will restart on it's own in about 2-3 minutes. Please do not open any programs. There is no need to click the OK button.")
? ' Installing '+$parsed
shell '%comspec% /c ' + $dir + ' -q -z -u -n -o'
$ = Writeprofilestring($logon+'\inventory\HotFix.log', $parsed, @wksta, @date)
$reboot = 1
endif
next
if $reboot
ShutDown ('', 'Updates have been applied that require to computer to restart', 5, 1, 1)
quit
endif
endif



Code:

;****************************************************************************************************
function arrenumkey($regkey)
dim $Keylist, $c
if not keyexist($regkey) exit 87 endif
do
$Key = $Key+'|'+enumkey($regkey,$c)
$c = $c + 1
until @error
$arrenumkey = split(substr($Key,2,len($Key)-2),'|')
Endfunction
;****************************************************************************************************
Function WshPipe($ShellCMD, OPTIONAL $NoEcho)
Dim $oExec, $Output
$oExec = CreateObject("WScript.Shell").Exec($ShellCMD)
If Not VarType($oExec)=9 $WshPipe="WScript.Shell Exec Unsupported" Exit 10 EndIf
While Not $oExec.Status Loop
$Output = $oExec.StdOut.ReadAll + $oExec.StdErr.ReadAll
If Not $NoEcho $Output Endif
$WshPipe=Split($Output,CHR(10))
Exit($oExec.ExitCode)
EndFunction
;****************************************************************************************************
Function arrEnumdir($directory, optional $mask, Optional $Subdir)
if $subdir $subdir='/s' endif
if exist($directory)
$E = WshPipe('%comspec% /c dir "$directory\$mask" /b $subdir',1)
redim preserve $e[ubound($e)-1]
$arrEnumdir=split(join($e,'|'),chr(13)+'|')
else
exit 87
endif
Endfunction


_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#108844 - 2003-11-25 10:53 PM Re: problem installing multiple patches at same time
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4629
Loc: The Netherlands
Quote:

No,

there is no wait option for KiX' run command.
You might want to go with SHELL command instead which waits for completion

hth




Not that good an option but one could put a sleep in it.
Would need to know the time it takes for each patch to run though.
Or just create a separate script for each patch and use call for each patch script from one main script..
Did the last thing for uninstalling acrobat reader 5, installing 6, installing W2K sp4 and reging kixforms.dll in one go and worked fine.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#108845 - 2003-11-26 07:30 AM Re: problem installing multiple patches at same time
Co Offline
MM club member
***

Registered: 2000-11-20
Posts: 1338
Loc: NL
You can use Qchain if you want to install multiple patches: Q296861 - How to Install Multiple Windows Updates or Hotfixes with Only One Reboot
_________________________
Co


Top
#108846 - 2004-01-24 10:05 AM Re: problem installing multiple patches at same time
Co Offline
MM club member
***

Registered: 2000-11-20
Posts: 1338
Loc: NL
Radimus,

I have used your script and I noticed a strange behaviour..

I have tested it on a Windows XP pc and there was no problem...

After that I tested it on a Windows 2000 Server and there was an Out of Bound error in line:

Code:
 redim preserve $e[ubound($e)-1] 



The only difference is hardware and OS...

Could it be a memory problem?


Edited by Co (2004-01-24 10:07 AM)
_________________________
Co


Top
#108847 - 2004-01-24 04:43 PM Re: problem installing multiple patches at same time
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
perhaps a bad dir?
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#108848 - 2004-01-25 12:07 AM Re: problem installing multiple patches at same time
Co Offline
MM club member
***

Registered: 2000-11-20
Posts: 1338
Loc: NL
everything is the same it only runs on an other pc with another OS..
_________________________
Co


Top
#108849 - 2004-01-25 06:52 PM Re: problem installing multiple patches at same time
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11162
Loc: Boston, MA, USA
Don't think it's the UDF. The 'out of bound' error would only happen if the array would have at most one element, thus $e[0].

You might want to step throught he code via DEBUG N to figure out what exactly is going on.
_________________________
There are two types of vessels, submarines and targets.

Top
#108850 - 2004-01-26 06:21 AM Re: problem installing multiple patches at same time
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22298
Loc: OK
I want to vote!
lets see, either bad dir or access denied.
k, I vote on access denied!
_________________________
!

download KiXnet

Top
#108851 - 2004-01-26 08:47 AM Re: problem installing multiple patches at same time
Co Offline
MM club member
***

Registered: 2000-11-20
Posts: 1338
Loc: NL
Both are executed with an administrator account and the Dir is the same... I pass...
_________________________
Co


Top
#108852 - 2004-01-26 08:49 AM Re: problem installing multiple patches at same time
Co Offline
MM club member
***

Registered: 2000-11-20
Posts: 1338
Loc: NL
Btw. Lonk, Where is your hair??

Edited by Co (2004-01-26 09:14 AM)
_________________________
Co


Top
#108853 - 2004-01-26 11:04 AM Re: problem installing multiple patches at same time
Co Offline
MM club member
***

Registered: 2000-11-20
Posts: 1338
Loc: NL
I have tested it again on other computers (one W2k Server and one XP Pro)
Same result XP = OK W2k = error.
I have tried it with a mapped drive and an UNC path but both gives this error...
_________________________
Co


Top
#108854 - 2004-01-26 02:52 PM Re: problem installing multiple patches at same time
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
modify the UDF like this for testing:

? "$directory\$mask"
shell '%comspec% /c dir "$directory\$mask" /b $subdir'
$E = WshPipe('%comspec% /c dir "$directory\$mask" /b $subdir',1)
? ubound($e)
redim preserve $e[ubound($e)-1]
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#108855 - 2004-01-27 03:31 PM Re: problem installing multiple patches at same time
Co Offline
MM club member
***

Registered: 2000-11-20
Posts: 1338
Loc: NL
Still an error.... I have tried everything, I almost smashed my pc on the ground...(Grrr)

Code:
 break on

;************************************ W2K HotFix Updates *****************************************
;Go c:
?""
?""
If @producttype="Windows 2000 Server"
$setup='\\server\srvpatch$'
$arrkey = arrEnumKey('HKLM\SOFTWARE\Microsoft\Updates\Windows 2000\SP5')
$arrdir = arrEnumDir($setup+'\w2k_hotfixes','*.exe',1)
$reboot = 0
For Each $Dir in $arrdir
$installed = 0
$parsed = Split($Dir,'-')[1]
For Each $key in $arrkey
If $key = $parsed
$installed = 1
EndIf
Next
If NOT $installed
$=SendMessage(@wksta,"A CRTICAL upgrade is now starting. Your computer will restart on it's own in about 2-3 minutes. Please do not open any programs. There is no need to click the OK button.")
? ' Installing '+$parsed
Shell '%comspec% /c ' + $Dir + ' -z -u -o' ; -q -n
;$ = WriteProfileString($logon+'\inventory\HotFix.log', $parsed, @wksta, @date)
$reboot = 1
EndIf
Next
If $reboot
Shutdown ('', 'Updates have been applied that require to computer to restart', 5, 1, 1)
Quit
EndIf
EndIf

;UDF's
;****************************************************************************************************
Function arrenumkey($regkey)
Dim $Keylist, $c
If NOT KeyExist($regkey) Exit 87 EndIf
Do
$Key = $Key+'|'+EnumKey($regkey,$c)
$c = $c + 1
Until @error
$arrenumkey = Split(SubStr($Key,2,Len($Key)-2),'|')
EndFunction
;****************************************************************************************************
Function WshPipe($ShellCMD, OPTIONAL $NoEcho)
Dim $oExec, $Output
$oExec = CreateObject("WScript.Shell").Exec($ShellCMD)
If NOT VarType($oExec)=9 $WshPipe="WScript.Shell Exec Unsupported" Exit 10 EndIf
While NOT $oExec.Status Loop
$Output = $oExec.StdOut.ReadAll + $oExec.StdErr.ReadAll
If NOT $NoEcho $Output EndIf
$WshPipe=Split($Output,Chr(10))
Exit($oExec.ExitCode)
EndFunction
;****************************************************************************************************
Function arrEnumdir($directory, optional $mask, Optional $Subdir)
If $subdir $subdir='/s' EndIf
If Exist($directory)
? "$directory\$mask"
shell '%comspec% /c dir "$directory\$mask" /b $subdir'
$E = WshPipe('%comspec% /c dir "$directory\$mask" /b $subdir',1)
? ubound($e)
redim preserve $e[ubound($e)-1]
? @ERROR+'-'+@serror
$arrEnumdir=Split(Join($e,'|'),Chr(13)+'|')
Else
Exit 87
EndIf
EndFunction



XP = still OK
Output W2K:

Code:
 

\\server\srvpatch$\w2k_hotfixes\ENU_Q832483_MDAC_x86.EXE
\\server\srvpatch$\w2k_hotfixes\Q331953_W2K_SP4_X86_EN.exe
\\server\srvpatch$\w2k_hotfixes\Q810833_W2K_SP4_X86_EN.exe
\\server\srvpatch$\w2k_hotfixes\Windows2000-KB817606-x86-ENU.exe
\\server\srvpatch$\w2k_hotfixes\Windows2000-KB823182-x86-ENU.exe
\\server\srvpatch$\w2k_hotfixes\Windows2000-KB823980-x86-ENU.exe
\\server\srvpatch$\w2k_hotfixes\Windows2000-KB824141-x86-ENU.exe
\\server\srvpatch$\w2k_hotfixes\Windows2000-KB824146-x86-ENU.exe
\\server\srvpatch$\w2k_hotfixes\Windows2000-KB825119-x86-ENU.exe
\\server\srvpatch$\w2k_hotfixes\Windows2000-KB826232-x86-ENU.exe
\\server\srvpatch$\w2k_hotfixes\Windows2000-KB828035-x86-ENU.exe
c:\WINNT\system32\cmd.exe /c dir "\\server\srvpatch$\w2k_hotfixes\*.exe" /b /s
-1
ERROR : array reference out of bounds!
Script: \\server\srvpatch$\W2k_hotfixes.kix
Line : 48



XP:
Quote:


OS Name Microsoft Windows XP Professional
Version 5.1.2600 Service Pack 1 Build 2600
OS Manufacturer Microsoft Corporation
System Name TESTPC2
System Manufacturer Hewlett-Packard
System Model HP d530 SFF(DC578AV)
System Type X86-based PC
Processor x86 Family 15 Model 2 Stepping 7 GenuineIntel ~2660 Mhz
BIOS Version/Date Hewlett-Packard 786B2 v2.04, 10/3/2003
SMBIOS Version 2.3
Windows Directory C:\WINDOWS
System Directory C:\WINDOWS\System32
Boot Device \Device\HarddiskVolume1
Locale United States
Hardware Abstraction Layer Version = "5.1.2600.1106 (xpsp1.020828-1920)"
User Name Domain\User
Time Zone W. Europe Standard Time
Total Physical Memory 512.50 MB
Available Physical Memory 264.24 MB
Total Virtual Memory 1.69 GB
Available Virtual Memory 1.26 GB
Page File Space 1.20 GB
Page File D:\pagefile.sys





W2K:
Quote:


OS Name Microsoft Windows 2000 Advanced Server
Version 5.0.2195 Service Pack 3 Build 2195
OS Manufacturer Microsoft Corporation
System Name SERVER1
System Manufacturer Compaq
System Model ProLiant ML370 G3
System Type X86-based PC
Processor x86 Family 15 Model 2 Stepping 7 GenuineIntel ~2780 Mhz
Processor x86 Family 15 Model 2 Stepping 7 GenuineIntel ~2780 Mhz
Processor x86 Family 15 Model 2 Stepping 7 GenuineIntel ~2780 Mhz
Processor x86 Family 15 Model 2 Stepping 7 GenuineIntel ~2780 Mhz
BIOS Version/Date Compaq P28, 1/8/2003
SMBIOS Version 2.3
Windows Directory C:\WINNT
System Directory C:\WINNT\system32
Boot Device \Device\Harddisk0\Partition1
Locale United States
Hardware Abstraction Layer Version = "5.00.2195.5201"
User Name Domain\admin
Time Zone W. Europe Standard Time
Total Physical Memory 2,560.00 MB
Available Physical Memory 797.78 MB
Total Virtual Memory 8.24 GB
Available Virtual Memory 4.79 GB
Page File Space 5.74 GB
Page File C:\pagefile.sys







Edited by Co (2004-01-27 04:12 PM)
_________________________
Co


Top
#108856 - 2004-01-27 04:19 PM Re: problem installing multiple patches at same time
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11162
Loc: Boston, MA, USA
Why not use any of the other DIR*() UDFs?
_________________________
There are two types of vessels, submarines and targets.

Top
#108857 - 2004-01-27 04:27 PM Re: problem installing multiple patches at same time
Co Offline
MM club member
***

Registered: 2000-11-20
Posts: 1338
Loc: NL
Good idea, I'm already busy with an alternative..
_________________________
Co


Top
#108858 - 2004-01-28 10:29 AM Re: problem installing multiple patches at same time
Co Offline
MM club member
***

Registered: 2000-11-20
Posts: 1338
Loc: NL
dirlist() did the job...

Code:

break on
;************************************ W2K HotFix Updates *****************************************
;Go c:
?""
?""
If @producttype="Windows 2000 Server"
$setup='\\server\srvpatch$'
$arrkey = arrEnumKey('HKLM\SOFTWARE\Microsoft\Updates\Windows 2000\SP5')
$arrdir = arrEnumDir($setup+'\w2k_hotfixes','*.exe',1)
$reboot = 0
For Each $Dir in $arrdir
$installed = 0
$parsed = Split($Dir,'-')[1]
For Each $key in $arrkey
If $key = $parsed
$installed = 1
EndIf
Next
If NOT $installed
$=SendMessage(@wksta,"A CRTICAL upgrade is now starting. Your computer will restart on it's own in about 2-3 minutes. Please do not open any programs. There is no need to click the OK button.")
? ' Installing '+$parsed
Shell '%comspec% /c ' + $Dir + ' -z -u -o' ; -q -n
;$ = WriteProfileString($logon+'\inventory\HotFix.log', $parsed, @wksta, @date)
$reboot = 1
EndIf
Next
If $reboot
Shutdown ('', 'Updates have been applied that require to computer to restart', 5, 1, 1)
Quit
EndIf
EndIf
;****************************************************************************************************
Function WshPipe($ShellCMD, OPTIONAL $NoEcho)
Dim $oExec, $Output
$oExec = CreateObject("WScript.Shell").Exec($ShellCMD)
If NOT VarType($oExec)=9 $WshPipe="WScript.Shell Exec Unsupported" Exit 10 EndIf
While NOT $oExec.Status Loop
$Output = $oExec.StdOut.ReadAll + $oExec.StdErr.ReadAll
If NOT $NoEcho $Output EndIf
$WshPipe=Split($Output,Chr(10))
Exit($oExec.ExitCode)
EndFunction
;****************************************************************************************************
;FUNCTION DirList
;
;AUTHOR Jens Meyer (sealeopard@usa.net)
;
;ACTION Returns an array with a list of files in a given directory
;
;VERSION 1.2
;
;KIXTART 4.12
;
;SYNTAX DIRLIST(DIRNAME [,OPTIONS])
;
;PARAMETERS DIRNAME
; Required string containing the directory name
;
; OPTIONS
; Optional value for additional options, options are set bitwise
; 1 = include directories (denoted by a backslash) that match the search mask
; 2 = include full path
; 4 = search all subdirectories
;
;RETURNS array with a list of files, otherwise an empty string
;
;REMARKS none
;
;DEPENDENCIES none
;
;EXAMPLE $dirlist = DIRLIST("c:\*.*",1+2+4)
;
;KIXTART BBS http://www.kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000090
;
Function dirlist($dirname, optional $options)
Dim $filename, $counter, $filepath, $mask
Dim $list, $sublist, $subcounter

$counter=-1

$dirname=Trim($dirname)
If $dirname=''
$dirname=@CURDIR
EndIf
If Right($dirname,1)='\'
$dirname=Left($dirname,Len($dirname)-1)
EndIf
If GetFileAttr($dirname) & 16
$mask='*.*'
Else
$mask=SubStr($dirname,InStrRev($dirname,'\')+1)
$dirname=Left($dirname,Len($dirname)-Len($mask)-1)
EndIf

ReDim $list[10]
$filename=Dir($dirname+'\'+$mask)
While $filename<>'' AND @ERROR=0
If $filename<>'.' AND $filename<>'..'
Select
Case (GetFileAttr($dirname+'\'+$filename) & 16)
If $options & 1
$counter=$counter+1
If $options & 2
$list[$counter]=$dirname+'\'+$filename+'\'
Else
$list[$counter]=$filename+'\'
EndIf
EndIf
If ($options & 4)
$sublist=dirlist($dirname+'\'+$filename+'\'+$mask,4)
If Ubound($sublist)+1
ReDim preserve $list[Ubound($list)+Ubound($sublist)+1]
For $subcounter=0 to Ubound($sublist)
$counter=$counter+1
If $options & 2
$list[$counter]=$dirname+'\'+$filename+'\'+$sublist[$subcounter]
Else
$list[$counter]=$filename+'\'+$sublist[$subcounter]
EndIf
Next
EndIf
EndIf
Case ($options & 2)
$counter=$counter+1
$list[$counter]=$dirname+'\'+$filename
Case 1
$counter=$counter+1
$list[$counter]=$filename
EndSelect
If $counter mod 10
ReDim preserve $list[$counter+10]
EndIf
EndIf
$filename = Dir('')
Loop

If $counter+1
ReDim preserve $list[$counter]
Else
$list=''
EndIf

If $mask<>'*.*' AND ($options & 4)
$filename=Dir($dirname+'\*.*')
While $filename<>'' AND @ERROR=0
If $filename<>'.' AND $filename<>'..'
If (GetFileAttr($dirname+'\'+$filename) & 16)
$sublist=dirlist($dirname+'\'+$filename+'\'+$mask,4)
If Ubound($sublist)+1
ReDim preserve $list[Ubound($list)+Ubound($sublist)+1]
For $subcounter=0 to Ubound($sublist)
$counter=$counter+1
If $options & 2
$list[$counter]=$dirname+'\'+$filename+'\'+$sublist[$subcounter]
Else
$list[$counter]=$filename+'\'+$sublist[$subcounter]
EndIf
Next
EndIf
EndIf
EndIf
$filename = Dir('')
Loop
EndIf

If $counter+1
ReDim preserve $list[$counter]
Else
$list=''
EndIf

$dirlist=$list
EndFunction

_________________________
Co


Top
#108859 - 2004-01-28 03:39 PM Re: problem installing multiple patches at same time
Co Offline
MM club member
***

Registered: 2000-11-20
Posts: 1338
Loc: NL
FYI,

Dirscan() gives the same error...
_________________________
Co


Top
Page 1 of 2 12>


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 177 anonymous users online.
Newest Members
dboozcruise, 2786707460, Marc57, EricMyers, siddharthinfosy
17519 Registered Users

Generated in 0.113 seconds in which 0.047 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org