#75277 - 2003-06-04 10:18 AM
KiX32 won't close down
|
Peredur ab Efrog
Fresh Scripter
Registered: 2002-06-17
Posts: 6
Loc: Cymru
|
I have a (lengthy) script which is going to be part of an even larger one. Its purpose is to download and install patches as they become available, when the user starts the system. They are installed by running pkunzip from within a KiX SHELL command.
It all works fine except that if patches are installed (i.e. the SHELL command is executed), the script will not exit.
Here's the script (Note that the MessageBox call immediately before the EndFunction is executed, but the following quit is not. The script exits normally (even without the quit) if the SHELL command is not executed):
;;;;;;;;;;;;;;;;;; Script ;;;;;;;;;;;;;;;;;;;;;
; Globals
$patchDirPath = "\\cimisweb\cimis\common\deployment\patches\8203\" $usysDir = "c:\usys82\" $patchLogFileName = "patchlog.txt"
InstallPatches()
Function InstallPatches Dim $WinVer Dim $patchLogFile Dim $empty $InstallPatches = 0 ; Is Uniface 8.2 installed? if not exist ( $usysDir ) MessageBox( "Error: Missing Usys82 Directory", "Patches", 16 ) quit -1 endif ; Does the patch directory path exist? if not exist ( $patchDirPath ) MessageBox( "Error: Missing Patch Directory Path", "Patches", 16 ) quit -1 endif
; Store the Windows Version
$WinVer = @ProductType
; Find the patch directory (don't need 95 or NT) $patchDir = TestAndSetPatchDir( $WinVer, "98" ) if $patchDir = "" $patchDir = TestAndSetPatchDir( $WinVer, "2000" ) if $patchDir = "" $patchDir = TestAndSetPatchDir( $WinVer, "XP" ) if $patchDir = "" MessageBox("Error: Unsupported Operating System", "CIMIS 2000 - Patches", 16) quit -1 endif endif endif
;MessageBox( "Windows Version is: " + $WinVer, "Patches", 64) ;MessageBox( "Patch directory is: " + $patchDir, "Patches", 64) if not exist ( $patchDir ) MessageBox( "Error: Patch Directory does not exist", "Patches", 16 ) quit -1 endif $patchLogFile = $usysDir + $patchLogFileName ;MessageBox( "Patch Log File is: " + $patchLogFile, "Patches", 64 ) $empty = 1 $patch = Dir( $patchDir ) While $patch = "." or $patch = ".." $patch = Dir() Loop
;$count = 0 While $patch <> "" and @ERROR = 0 ;$count = $count + 1 ;MessageBox("Loop iteration no: " + $count, "Patches", 64)
if $empty = 1 $empty = 0 endif ; Create the patches log file if it doesn't exist, and open it for reading if open( 4, $patchLogFile, 3 ) = 0
; read a line from the patch log file $lineFromPatchLogFile = ReadLine( 4 ) while $patch <> $lineFromPatchLogFile and @ERROR = 0 $lineFromPatchLogFile = ReadLine( 4 ) loop $saveError = @ERROR endif close ( 4 ) ;MessageBox("saveError is: " + $saveError + @CRLF + "patch is: " + $patch + @CRLF + "lineFromPatchLogFile is: " + $linefrompatchfile, "Patches", 64) if $saveError = -1 or $patch <> $lineFromPatchLogfile MessageBox( "Installing patch: " + $patch, "CIMIS2000 - Patches", 64 ) ; do pkunzip stuff $cmd = "m:\common\deployment\pkunzip.exe -d " + $patchDir + $patch + " " + $usysDir + " -o" shell $cmd ; open patch log file for writing (error if doesn't exist) if open( 4, $patchLogFile, 4 ) = 0 ; append patch file name to patch log file (+CRLF) WriteLine( 4, $patch + @CRLF ) ; close patch log file close( 4 ) else MessageBox( "Error: Couldn't open patch log file!", "CIMIS 2000 - Patches", 16 ) quit -1 endif endif $patch = Dir() ; retrieve next file ;MessageBox("Error code is: " + @ERROR + @CRLF + "Next patch is: " + $patch, "Patches", 64) Loop MessageBox("Left loop", "Patches", 64) if $empty = 1 ; patch directory is empty MessageBox("Patch file empty. Nothing to do", "Patches", 64) ; delete the patch log file if exist ( $patchLogFile ) del $patchLogFile endif endif MessageBox("Leaving Function", "Patches", 64) quit 0 EndFunction
Function TestAndSetPatchDir( $windowsVersion, $pattern ) $TestAndSetPatchDir = "" $startIndex = INSTR ($windowsVersion, $pattern ) if $startIndex > 0 $TestAndSetPatchDir = $patchDirPath + "W" + $pattern + "\" Endif EndFunction
|
|
Top
|
|
|
|
#75279 - 2003-06-04 01:17 PM
Re: KiX32 won't close down
|
Peredur ab Efrog
Fresh Scripter
Registered: 2002-06-17
Posts: 6
Loc: Cymru
|
Thanks for the suggestion.
Actually, I am sure it finishes. It executes code following the shell command - even outside of the loop in which the shell command is called.
It works fine with WinZip, but I only have an evaluation copy.
Anyway, I'll try your suggestion (after lunch) and let you know if it works. Thanks again.
Peter
|
|
Top
|
|
|
|
#75282 - 2003-06-04 10:19 PM
Re: KiX32 won't close down
|
Kdyer
KiX Supporter
   
Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
|
I don't think that is the point. He is looking to use a command-line zipper. If it not "registered" to him, he has one of two options - find a free one or register (purchase) one.
Kent
|
|
Top
|
|
|
|
#75284 - 2003-06-04 11:03 PM
Re: KiX32 won't close down
|
Kdyer
KiX Supporter
   
Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
|
Hmm..
quote:
It works fine with WinZip, but I only have an evaluation copy.
Kent
|
|
Top
|
|
|
|
#75286 - 2003-06-05 03:46 PM
Re: KiX32 won't close down
|
Peredur ab Efrog
Fresh Scripter
Registered: 2002-06-17
Posts: 6
Loc: Cymru
|
Guys,
You've all been really helpful.
The %COMSPEC% suggestion didn't work, I'm afraid. However, since these are actually self-extracting archives, we managed to get around the problem by calling them directly and then using AutoIt to type in the proper directory for extraction, and to close the various windows by sending a series of carriage return characters. AutoIt can produce an executable that can be called from the KiX script, passing in any required parameters (the file name in this case).
Thanks again (Ac ydw. 'Dwi o Gymru. Ond ddim yn wreiddiol. Mae cliw yn yr enw ynglyn a ble ces i fy ngeni!)
Peter (Peredur ab Efrog)
|
|
Top
|
|
|
|
#75287 - 2003-06-05 04:33 PM
Re: KiX32 won't close down
|
Kdyer
KiX Supporter
   
Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
|
Need to create an executable for KiXtart? Look into KiXCrypt..
Thanks,
Kent
|
|
Top
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 937 anonymous users online.
|
|
|