#108840 - 2003-11-25 12:05 PM
problem installing multiple patches at same time
|
zigi
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
|
|
|
|
#108842 - 2003-11-25 01:08 PM
Re: problem installing multiple patches at same time
|
zigi
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
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
|
Top
|
|
|
|
#108847 - 2004-01-24 04:43 PM
Re: problem installing multiple patches at same time
|
Radimus
Moderator
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
|
Top
|
|
|
|
#108854 - 2004-01-26 02:52 PM
Re: problem installing multiple patches at same time
|
Radimus
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]
|
Top
|
|
|
|
#108855 - 2004-01-27 03:31 PM
Re: problem installing multiple patches at same time
|
Co
MM club member
Registered: 2000-11-20
Posts: 1341
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
|
|
|
|
#108858 - 2004-01-28 10:29 AM
Re: problem installing multiple patches at same time
|
Co
MM club member
Registered: 2000-11-20
Posts: 1341
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
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
1 registered
(Allen)
and 382 anonymous users online.
|
|
|