Sign in to follow this  
Followers 0
chiners_68

A Little help with if file exisits

5 posts in this topic

Right ive got the following. when it runs the if file exisits part then

when it gets to the else it stops. how can I solve this..

if the file exists I want the complete unstall then install to run. If it dosent i just want the install to run which works. aftewr the uninstall has run it dosent run the install section. why would this be & how do i solve it.?

di I have to copy the install section & push the else install section down. shorly I dont have to have the install section twice..

;Previous Version removal

if FileExists("C:\PROGRA~1\COMPAS~1\PROACH~1\UNWISE.EXE") then

run("C:\PROGRA~1\COMPAS~1\PROACH~1\UNWISE.EXE")

winwait("ProAchieve/ProTarget", "Select Uninstall Method")

Send("{ENTER}")

winwait("ProAchieve/ProTarget", "Perform Uninstall")

Send("{ENTER}")

;winwait("Remove Shared Component")

;Send("!a")

winwaitclose("ProAchieve/ProTarget")

DirRemove ("C:\Program Files\CompassCC", 1)

;Install ProAchieve 7.2.4

Else

Run("\\lan-img-01\it$\Software\Other\CompassCC\ProAchieve_V7.2.4\setup.exe")

winwait("Welcome", "Welcome to the ProAchieve/ProTarget Setup program.")

Send("!n")

winwait("ProAchieve/ProTarget Installation / Upgrade", "Please select the required installation type.")

Send("!n")

winwait("ProAchieve/ProTarget Installation", "Select the elements of ProAchieve/ProTarget to install")

ControlClick("ProAchieve/ProTarget Installation", "ProAchieve/ProTarget 7 Data Files", 8)

Send("!n")

winwait("ProAchieve/ProTarget Installation", "Select Destination Directory")

Send("!n")

winwait("Select Program Manager Group", "Enter the name of the Program Manager group to add ProAchieve/ProTarget icons to:")

Send("!n")

winwait("Backup Replaced Files", "This installation program can create backup copies of all files replaced during the installation.")

Send("!y")

Send("!n")

winwait("Start Installation", "You are now ready to install ProAchieve/ProTarget.")

Send("!n")

winwait("Installation Complete", "ProAchieve/ProTarget has been successfully installed.")

Send("!f")

Sleep(1000)

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

when it gets to the else it stops. how can I solve this..

Simple : replace that "else" with an "endif", and delete the origional "endif" :)

By the way : Where is the origional "endif" anyway ? Should it be at the bottom and have you just forgotten to copy it ?

Edited by BitRot

Share this post


Link to post
Share on other sites

BitRot,

the end if was further down. I just didnt copy that when I was pasting the script above..

so i need to remove the else & put the enif after the first section.?

Share this post


Link to post
Share on other sites

HI,

;Previous Version removal

If FileExists("C:\PROGRA~1\COMPAS~1\PROACH~1\UNWISE.EXE") Then
    uninstall ()
    install()
Else
    install()
EndIf

Func uninstall ()
    Run("C:\PROGRA~1\COMPAS~1\PROACH~1\UNWISE.EXE")
    WinWait("ProAchieve/ProTarget", "Select Uninstall Method")
    Send("{ENTER}")
    WinWait("ProAchieve/ProTarget", "Perform Uninstall")
    Send("{ENTER}")
    ;winwait("Remove Shared Component")
    ;Send("!a")
    WinWaitClose("ProAchieve/ProTarget")
    DirRemove("C:\Program Files\CompassCC", 1)
EndFunc   ;==>uninstall

;Install ProAchieve 7.2.4
Func install()
    Run("\\lan-img-01\it$\Software\Other\CompassCC\ProAchieve_V7.2.4\setup.exe")
    WinWait("Welcome", "Welcome to the ProAchieve/ProTarget Setup program.")
    Send("!n")
    WinWait("ProAchieve/ProTarget Installation / Upgrade", "Please select the required installation type.")
    Send("!n")
    WinWait("ProAchieve/ProTarget Installation", "Select the elements of ProAchieve/ProTarget to install")
    ControlClick("ProAchieve/ProTarget Installation", "ProAchieve/ProTarget 7 Data Files", 8)
    Send("!n")
    WinWait("ProAchieve/ProTarget Installation", "Select Destination Directory")
    Send("!n")
    WinWait("Select Program Manager Group", "Enter the name of the Program Manager group to add ProAchieve/ProTarget icons to:")
    Send("!n")
    WinWait("Backup Replaced Files", "This installation program can create backup copies of all files replaced during the installation.")
    Send("!y")
    Send("!n")
    WinWait("Start Installation", "You are now ready to install ProAchieve/ProTarget.")
    Send("!n")
    WinWait("Installation Complete", "ProAchieve/ProTarget has been successfully installed.")
    Send("!f")
    Sleep(1000)
EndFunc   ;==>install

So long,

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

BitRot,

the end if was further down. I just didnt copy that when I was pasting the script above..

I allready assumed as much :)

so i need to remove the else & put the enif after the first section.?

Yes. Only the de-installation process is conditional, the installation process should be executed allways (and should therefore not be inside an "if" or else").

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0