Page 1 of 1 1
Topic Options
#31867 - 2002-11-06 11:05 AM Using kix to run exe with conditions
Stephen Wintle Offline
Seasoned Scripter

Registered: 2001-04-10
Posts: 444
Loc: England
Hi, could anybody help me with what I am doing. currently im trying to get a packaged prog. to run using DOS batch (not working) that checks for an exe and if its not their will run installion, if it is their it will ignore and just run prog. Can this be achieved in kix? this is my dos ver.

code:
 

IF NOT EXIST C:\PROGRA~1\ADOBE\ACROBA~1.0\Reader\AcroRd32.exe GOTO INSTALL
:INSTALL
P:\ADOBE\ADOBE.EXE
:END
C:\PROGRA~1\ADOBE\ACROBA~1.0\Reader\AcroRd32.exe


_________________________
Dont worry because a rival imitates you. As long as they follow in your tracks they cant pass you!

Top
#31868 - 2002-11-06 11:59 AM Re: Using kix to run exe with conditions
Mit Offline
Fresh Scripter

Registered: 2002-06-05
Posts: 36
Loc: Derby, UK
use else/if

[ 06. November 2002, 12:00: Message edited by: Mit ]

Top
#31869 - 2002-11-07 12:34 AM Re: Using kix to run exe with conditions
Stephen Wintle Offline
Seasoned Scripter

Registered: 2001-04-10
Posts: 444
Loc: England
Tried the following but to no avail.
code:
  
IF EXIST ("C:\PROGRA~1\ADOBE\ACROBA~1.0\Reader\AcroRd32.exe" =0)
RUN P:\ADOBE\ADOBE.EXE
ELSE
RUN C:\PROGRA~1\ADOBE\ACROBA~1.0\Reader\AcroRd32.exe
EXIT

_________________________
Dont worry because a rival imitates you. As long as they follow in your tracks they cant pass you!

Top
#31870 - 2002-11-07 12:43 AM Re: Using kix to run exe with conditions
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Stephen, reading the manual to get the proper commands and syntax would help you greatly.

code:
IF NOT EXIST ("C:\PROGRA~1\ADOBE\ACROBA~1.0\Reader\AcroRd32.exe")
RUN "P:\ADOBE\ADOBE.EXE"
ELSE
RUN "C:\PROGRA~1\ADOBE\ACROBA~1.0\Reader\AcroRd32.exe"
Endif

or
code:
IF EXIST ("C:\PROGRA~1\ADOBE\ACROBA~1.0\Reader\AcroRd32.exe") = 0
RUN "P:\ADOBE\ADOBE.EXE"
ELSE
RUN "C:\PROGRA~1\ADOBE\ACROBA~1.0\Reader\AcroRd32.exe"
Endif

_________________________
Home page: http://www.kixhelp.com/hb/

Top
#31871 - 2002-11-06 03:28 PM Re: Using kix to run exe with conditions
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Even after reading all the posts, I'm still not sure what the objective is. I think that you want to first test to see if Acrobat is installed. If not then install. Then or else open it.

Checking for the existence of the file is not good practice. Also the installation can be repackaged as silent.

Here is a beta script I've got on the back burner that checks the registry to see what version of Acrobat is installed and to uninstall all but the latest version. As a beta, the action lines are commented out.

code:
break on
;Search for "Acrobat Uninstall"
$Index = 0
:Loop1
$KeyName = ENUMKEY("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\", $Index)
If @ERROR = 0
If InStr("$KeyName","Acrobat")
"Name found: $KeyName" ?
Select
Case $KeyName = "Adobe Acrobat Reader 3.0"
"Uninstall Acrobat 3.0" ?
$UninstallStr = READVALUE("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Adobe Acrobat Reader 3.0","UninstallString")
;SHELL $UninstallStr + " -A"
"Complete." ?

Case $KeyName = "Adobe Acrobat Reader 3.01"
"Uninstall Acrobat 3.01" ?
$UninstallStr = READVALUE("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Adobe Acrobat Reader 3.01","UninstallString")
;SHELL $UninstallStr + " -A"
"Complete." ?

Case $KeyName = "Adobe Acrobat 4.0"
"Uninstall Acrobat 4.0" ?
$UninstallStr = READVALUE("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Adobe Acrobat 4.0","UninstallString")
;SHELL $UninstallStr + " -A"
"Complete." ?

Case $KeyName = "Adobe Acrobat 5.0"
"Leave alone" ?
Goto Done

Case 1
"OH OH, Not sure what to do!" ?

EndSelect
EndIf
$Index = $Index + 1
goto Loop1
EndIf

"Install Acrobat 5.05" ?
;shell 'path\setup.exe /s'

:Done

get $_

_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#31872 - 2002-11-06 03:36 PM Re: Using kix to run exe with conditions
Sealeopard Offline
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
#31873 - 2002-11-06 03:41 PM Re: Using kix to run exe with conditions
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
btw...

no need to make a iss file for adobe products.

you merely need to edit the Abcpy.ini file
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#31874 - 2002-11-08 02:23 PM Re: Using kix to run exe with conditions
Stephen Wintle Offline
Seasoned Scripter

Registered: 2001-04-10
Posts: 444
Loc: England
Thanks for everyones help with this, if checking for files rather than a key is bad practice why is this? I assume because software can be installed into dif. locations? Also, once my app is installed is their a simple way I can force it to run else my pupils are having to run the icon again...

Thanks again

Steve.
_________________________
Dont worry because a rival imitates you. As long as they follow in your tracks they cant pass you!

Top
#31875 - 2002-11-08 02:33 PM Re: Using kix to run exe with conditions
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Radimus:

With regards to the Adobe products install routine, that is true. However, in general silent installs based on e.g. the InstallShield installer will normally require the recording of a .ISS file in order to achieve an non-interactive silent install. I was outlining the more general approach so that the routine can be adapted to other application installs.
_________________________
There are two types of vessels, submarines and targets.

Top
#31876 - 2002-11-08 02:42 PM Re: Using kix to run exe with conditions
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
That's fine... I was just being specific [Smile]
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#31877 - 2002-11-08 07:03 PM Re: Using kix to run exe with conditions
Waltz Offline
Seasoned Scripter

Registered: 2002-08-01
Posts: 485
Loc: Waterloo, Ontario, Canada
quote:
Also, once my app is installed is their a simple way I can force it to run else my pupils are having to run the icon again...
Depends what you mean by forcing it to run (ie. when?)
If you want it to run as a final step of your install, you can force it with a 'runonce' procedure. This will help with that -->RunOnce()

Putting a shortcut to the app in All Users\Start Menu\Programs\Startup will force it to run at every login.

[ 08. November 2002, 19:27: Message edited by: Waltz ]
_________________________
We all live in a Yellow Subroutine...

Top
Page 1 of 1 1


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

Who's Online
0 registered and 584 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.067 seconds in which 0.031 seconds were spent on a total of 12 queries. Zlib compression enabled.

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