zigi
|
(Fresh Scripter)
|
2003-11-25 12:05 PM
|
|
|
|
|
problem installing multiple patches at same time
|
|
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
|
Jochen
|
(KiX Supporter)
|
2003-11-25 12:16 PM
|
|
|
|
|
Re: problem installing multiple patches at same time
|
|
No,
there is no wait option for KiX' run command. You might want to go with SHELL command instead which waits for completion
hth
|
zigi
|
(Fresh Scripter)
|
2003-11-25 01:08 PM
|
|
|
|
|
Re: problem installing multiple patches at same time
|
|
great. thank you. the shell-command is the solution.
|
Radimus
|
(KiX Supporter)
|
2003-11-25 01:23 PM
|
|
|
|
|
Re: problem installing multiple patches at same time
|
|
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
|
Mart
|
(KiX Supporter)
|
2003-11-25 10:53 PM
|
|
|
|
|
Re: problem installing multiple patches at same time
|
|
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.
|
Co
|
(MM club member)
|
2003-11-26 07:30 AM
|
|
|
|
|
Re: problem installing multiple patches at same time
|
|
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
|
(MM club member)
|
2004-01-24 10:05 AM
|
|
|
|
|
Re: problem installing multiple patches at same time
|
|
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?
|
Radimus
|
(KiX Supporter)
|
2004-01-24 04:43 PM
|
|
|
|
|
Re: problem installing multiple patches at same time
|
|
perhaps a bad dir?
|
Co
|
(MM club member)
|
2004-01-25 12:07 AM
|
|
|
|
|
Re: problem installing multiple patches at same time
|
|
everything is the same it only runs on an other pc with another OS..
|
|
Re: problem installing multiple patches at same time
|
|
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.
|
Lonkero
|
(KiX Master Guru)
|
2004-01-26 06:21 AM
|
|
|
|
|
Re: problem installing multiple patches at same time
|
|
I want to vote! lets see, either bad dir or access denied. k, I vote on access denied!
|
Co
|
(MM club member)
|
2004-01-26 08:47 AM
|
|
|
|
|
Re: problem installing multiple patches at same time
|
|
Both are executed with an administrator account and the Dir is the same... I pass...
|
Co
|
(MM club member)
|
2004-01-26 08:49 AM
|
|
|
|
|
Re: problem installing multiple patches at same time
|
|
Btw. Lonk, Where is your hair??
|
Co
|
(MM club member)
|
2004-01-26 11:04 AM
|
|
|
|
|
Re: problem installing multiple patches at same time
|
|
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...
|
Radimus
|
(KiX Supporter)
|
2004-01-26 02:52 PM
|
|
|
|
|
Re: problem installing multiple patches at same time
|
|
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]
|
Co
|
(MM club member)
|
2004-01-27 03:31 PM
|
|
|
|
|
Re: problem installing multiple patches at same time
|
|
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
|
|
Re: problem installing multiple patches at same time
|
|
Why not use any of the other DIR*() UDFs?
|
Co
|
(MM club member)
|
2004-01-27 04:27 PM
|
|
|
|
|
Re: problem installing multiple patches at same time
|
|
Good idea, I'm already busy with an alternative..
|
Co
|
(MM club member)
|
2004-01-28 10:29 AM
|
|
|
|
|
Re: problem installing multiple patches at same time
|
|
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
|
(MM club member)
|
2004-01-28 03:39 PM
|
|
|
|
|
Re: problem installing multiple patches at same time
|
|
FYI,
Dirscan() gives the same error...
|
Radimus
|
(KiX Supporter)
|
2004-04-16 03:31 PM
|
|
|
|
|
Re: problem installing multiple patches at same time
|
|
just to refresh the post for the new patches that just came out...
Code:
;************************************ W2K HotFix Updates ***************************************** $arrkey = arrEnumKey('HKLM\SOFTWARE\Microsoft\Updates\Windows 2000\SP5') $arrdir = FileList($setup+'\Win2k_Hotfixes','.exe',1) if not @error $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 CRITICAL 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' $reboot = 1 endif next if $reboot ShutDown ('', 'Updates have been applied that require to computer to restart', 5, 1, 1) quit endif endif
;**************************************************************************************************** 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 FileList($folderName,optional $mask, optional $path) Dim $objDir, $fullpath, $t, $objfile $objDir = CreateObject("Scripting.FileSystemObject") if not @error ; usually folder not found $files=$objDir.GetFolder($folderName).Files $Fullpath=iif($path,$foldername+'\','') For Each $objFile In $files $name=$objFile.name if ($mask and instr($name,$mask)) or not $mask $t=$t+'|'+$Fullpath+$name endif Next $FileList=split(substr($t,2),'|') else ; ?color r+/n 'FSO Create Object error: ' @serror color w/n endif exit iif(len($t)>1,0,1) EndFunction
|