#31872 - 2002-11-06 03:36 PM
Re: Using kix to run exe with conditions
|
Sealeopard
KiX Master
   
Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
|
Don't use the 8.3 notiation for filenames, rather put the complete path/filename in quotes.
Below is the Acrobat/Acrobat Reader install routine that is part of KSMS. It checks for the presence of Acrobat/Acrobat Reader and updates/installes the programs if necessary.
However, it does require some preparation. 1) I recorded a silent install for each program using the -r silent install option which creates a.ISS file (see also installer/application documentation for silent installs) 2) The install routine runs under administrative privileges under Windows NT/2000/XP 3) It uninstalls Acrobat 4.0 is present 4) Contains some error checking routines (disk space, file replacement on reboot) that could result in failed installation
code:
;------------------------------------- ; subroutine to install Adobe Acrobat 5.0 or Adobe Acrobat Reader 5.0 ;------------------------------------- :ACROBAT Dim $retcode, $readerkey, $readervalue, $readerexe, $readerversion, $shellcommand, $readeruninstall Dim $acrobatpresent, $acrobatdir, $acrobatcomps
if diskspace()<100000 gosub CHECKHDSPACE return endif
$acrobatpresent=0
; check whether Adobe Acrobat Reader is installed $readerkey=$HKLM+'\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\AcroRD32.exe' $readervalue='' if keyexist($readerkey) $readerexe=readvalue($readerkey,$readervalue) if exist($readerexe) $acrobatpresent=1 $readerversion=getfileversion($readerexe,'ProductVersion') $retcode=displaytext('Found Adobe Acrobat Reader '+$readerversion) if compareversions($readerversion,'5.0.5.0')<0 $retcode=displaytext('Preparing uninstalling of Adobe Acrobat Reader '+$readerversion) $readerkey=$HKLM+'\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Adobe Acrobat 4.0' $readervalue='UninstallString' if keyexist($readerkey) $readeruninstall=READVALUE($readerkey,$readervalue) $retcode=displaytext('Uninstalling Adobe Acrobat Reader '+$readerversion) $shellcommand=$readeruninstall+' -A' $retcode=shellcmd($shellcommand,1) endif
if checkupdateonreboot()<>0 $retcode=displaytext('Aborting installation of Adobe Acrobat Reader due to scheduled file replacements on reboot') else if getdiskspace('%WINDIR%')>30000 $retcode=displaytext('Installing Adobe Acrobat Reader 5.0.5') $shellcommand=fullfile($DEPLOYDIR,'acroread5\setup.exe -SMS -z') $retcode=shellcmd($shellcommand,1) $REBOOTREQUIRED=1 else $retcode=sendmessage(@WKSTA,'Diskspace is getting low. Please clean up!') endif endif else $retcode=displaytext('Latest version of Adobe Acrobat Reader is installed') endif else $retcode=warning('Cannot find file '+$readerexe) $acrobatpresent=0 endif else $retcode=displaytext('Adobe Acrobat Reader is not installed') $acrobatpresent=0 endif
; check whether Adobe Acrobat is installed $readerkey=$HKLM+'\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\Acrobat.exe' $readervalue='' if keyexist($readerkey) $readerexe=readvalue($readerkey,$readervalue) if exist($readerexe) $acrobatpresent=1 $readerversion=getfileversion($readerexe,'ProductVersion') $retcode=displaytext('Found Adobe Acrobat '+$readerversion) select case compareversions($readerversion,'5.0.0.0')<0 ; install Adobe Acrobat 5.0.0.0 $retcode=displaytext('Preparing uninstalling of Adobe Acrobat '+$readerversion) $readerkey=$HKLM+'\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Adobe Acrobat 4.0' $readervalue='UninstallString' if keyexist($readerkey) $readeruninstall=READVALUE($readerkey,$readervalue) $retcode=displaytext('Uninstalling Adobe Acrobat '+$readerversion) $shellcommand=$readeruninstall+' -A' $retcode=shellcmd($shellcommand,1)
if checkupdateonreboot()<>0 $retcode=displaytext('Aborting installation of Adobe Acrobat due to scheduled file replacements on reboot') else if getdiskspace('%WINDIR%')>120000 $retcode=displaytext('Installing Adobe Acrobat 5.0') $shellcommand=fullfile($DEPLOYDIR,'acrobat5\setup.exe -SMS -z') $retcode=shellcmd($shellcommand,1) $REBOOTREQUIRED=1 else $retcode=sendmessage(@WKSTA,'Diskspace is getting low. Please clean up!') endif endif endif case compareversions($readerversion,'5.0.5.0')<0 ; update Adobe Acrobat 5.x to 5.0.5 if checkupdateonreboot()<>0 $retcode=displaytext('Aborting upgrade of Adobe Acrobat due to scheduled file replacements on reboot') else if getdiskspace('%WINDIR%')>120000 $retcode=displaytext('Updating Adobe Acrobat to version 5.0.5') $shellcommand=fullfile($DEPLOYDIR,'acrobat505update\setup.exe -s -SMS -z') $retcode=shellcmd($shellcommand,1) $REBOOTREQUIRED=1 else $retcode=sendmessage(@WKSTA,'Diskspace is getting low. Please clean up!') endif endif case 1 $retcode=displaytext('Latest version of Acrobat is installed') endselect else $retcode=warning('Cannot find file '+$readerexe) endif else $retcode=displaytext('Adobe Acrobat is not installed') $acrobatcomps=readprofilestring($SCRIPTINI,'Software','AdobeAcrobat') $acrobatcomps=atrim(split($acrobatcomps,',')) if isinarray(@WKSTA,$acrobatcomps) $retcode=displaytext('Adobe Acrobat 5.0 is required for this computer') if checkupdateonreboot()<>0 $retcode=displaytext('Aborting installation of Adobe Acrobat due to scheduled file replacements on reboot') else if getdiskspace('%WINDIR%')>120000 $retcode=displaytext('Installing Adobe Acrobat 5.0') $shellcommand=fullfile($DEPLOYDIR,'acrobat5\setup.exe -SMS -z') $retcode=shellcmd($shellcommand,1) $REBOOTREQUIRED=1 else $retcode=sendmessage(@WKSTA,'Diskspace is getting low. Please clean up!') endif endif endif endif
; install Adobe Acrobat Reader 5.0.5 if no Acrobat product present at all if $acrobatpresent=0 $retcode=warning('No Adobe Acrobat product found. Installing Adobe Acrobat Reader 5.0.5') $shellcommand=fullfile($SCRIPTDIRECTORY,'deploy\acroread5\setup.exe -SMS -z')
if checkupdateonreboot()<>0 $retcode=displaytext('Aborting installation of Adobe Acrobat Reader due to scheduled file replacements on reboot') else if getdiskspace('%WINDIR%')>30000 $retcode=shellcmd($shellcommand,1) $REBOOTREQUIRED=1 else $retcode=sendmessage(@WKSTA,'Diskspace is getting low. Please clean up!') endif endif endif
; move the Adobe Acrobat Reader link to correct location $acrobatexe=fullfile($COMMONPROGRAMS,'Acrobat Reader 5.0.lnk') $acrobatdir=fullfile($COMMONPROGRAMS,'\Adobe\') if exist($acrobatexe) if $VERBOSE $retcode=displaytext('Moving Adobe link '+$acrobatexe+' to '+$acrobatdir) endif if not exist($acrobatdir) if $VERBOSE $retcode=displaytext('Creating directory '+$acrobatdir) endif md $acrobatdir endif copy $acrobatexe $acrobatdir del $acrobatexe endif
; move the Adobe Acrobat link to correct location $acrobatexe=fullfile($COMMONPROGRAMS,'Adobe Acrobat 5.0.lnk') $acrobatdir=fullfile($COMMONPROGRAMS,'Adobe\') if exist($acrobatexe) if $VERBOSE $retcode=displaytext('Moving Adobe link '+$acrobatexe+' to '+$acrobatdir) endif if not exist($acrobatdir) if $VERBOSE $retcode=displaytext('Creating directory '+$acrobatdir) endif md $acrobatdir endif copy $acrobatexe $acrobatdir del $acrobatexe endif
; move the Adobe Distiller link to correct location $acrobatexe=fullfile($COMMONPROGRAMS,'Acrobat Distiller 5.0.lnk') $acrobatdir=fullfile($COMMONPROGRAMS,'Adobe\') if exist($acrobatexe) if $VERBOSE $retcode=displaytext('Moving Adobe link '+$acrobatexe+' to '+$acrobatdir) endif if not exist($acrobatdir) if $VERBOSE $retcode=displaytext('Creating directory '+$acrobatdir) endif md $acrobatdir endif copy $acrobatexe $acrobatdir del $acrobatexe endif
return
[ 06. November 2002, 15:40: Message edited by: sealeopard ]
_________________________
There are two types of vessels, submarines and targets.
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 661 anonymous users online.
|
|
|