Sign in to follow this  
Followers 0
GeekOrGuru

Help w/FileExists PLEEEZZZ

7 posts in this topic

This does not work...

#region --- System Check ---
; This section checks to see if the application is already installed on the local computer.
; If it is not, then it installs it; if it is it verifies the version and installation log file;
; if a previous version is installed on the local computer, it uninstalls it and reinstalls the
; current version.
If Not FileExists("C:\Program Files\Expedite" Or "C:\Expedite") Then
        Call ("_Install")
    ElseIf FileExists("C:\Program Files\Expedite\5.9a") Then
        Call("_LogFile")
    Else
        Call("_Uninstall")
EndIf
#endregion --- System Check ---

This does?

#region --- System Check ---
; This section checks to see if the application is already installed on the local computer.
; If it is not, then it installs it; if it is it verifies the version and installation log file;
; if a previous version is installed on the local computer, it uninstalls it and reinstalls the
; current version.
If Not FileExists("C:\Program Files\Expedite") Then
        Call ("_Install")
    ElseIf FileExists("C:\Program Files\Expedite\5.9a") Then
        Call("_LogFile")
    Else
        Call("_Uninstall")
EndIf
#endregion --- System Check ---

So, can the "Or" operator not be utilized in this statement? I need to check both install locations somehow.

Share this post


Link to post
Share on other sites



#4 ·  Posted (edited)

~

Edited by Mobius

Share this post


Link to post
Share on other sites

Thanks guys! Got it working now.

I changed the order around in the If statements and used a combination of your replies. I did need to check both locations so I had to utilize the "Or" operator, but I utilized the response flag this time.

I know alot of this can probably be written more effectively, but it is only my second script utilizing AutoIt...thus I'm still a newbie learner!

#region --- BidX5.9a Installation Script ---

#region --- Variables ---
; This section contains "Variables" which are utilized or called upon throughout the script.
Dim $sUserName, $sPassword, $sDomain, $sSharePath, $sLogFilesPath, $sAppPath
$sUserName = "XXXXXXX"
$sPassword = "XXXXXXX"
$sDomain = "XXXXXXX"
$sSharePath = "\\FILE01\Public\Downloads\BidX 5.9a"
$sLogFilesPath = $sSharePath & "\LogFiles"
$sAppPath = $sSharePath & "\setup.exe"
#endregion --- Variables ---

#region --- System Check ---
; This section checks to see if the application is already installed on the local computer.
; If it is it verifies the version and installation log file; if a previous version is installed
; on the local computer, it uninstalls it and reinstalls the current version. If it is not installed,
; then it installs it.

If FileExists("C:\Program Files\Expedite\5.9a") Then
        Call("_LogFile")
    ElseIf FileExists("C:\Program Files\Expedite") = 1  Or FileExists("C:\Expedite") = 1 Then
        Call("_Uninstall")
    Else
        Call("_Install")
EndIf
#endregion --- System Check ---

#region --- Uninstall ---
; This section searches for previous installations and if present removes them.
Func _Uninstall()
    If FileExists("C:\Program Files\Expedite") Then
        DirRemove("C:\Program Files\Expedite", 1)
    EndIf

    If FileExists("C:\Expedite") Then
        DirRemove("C:\Expedite", 1)
    EndIf

    If FileExists("C:\Documents and Settings\All Users\Start Menu\Programs\Expedite") Then
        DirRemove("C:\Documents and Settings\All Users\Start Menu\Programs\Expedite", 1)
    EndIf
EndFunc
#endregion --- Uninstall ---

#region --- Install Routine ---
    #region --- Install Function ---
    Func _Install($title,$text,$timeout=0)
        WinWait($title,$text,$timeout)
        If Not WinActive($title,$text) Then WinActivate($title,$text)
        WinWaitActive($title,$text,$timeout)
    EndFunc
    #endregion --- Install Function ---

    #region --- Install Function Options ---
    Opt("WinWaitDelay",100)
    Opt("WinDetectHiddenText",1)
    Opt("MouseCoordMode",0)
    #endregion --- Install Function Options ---

    #region --- Application Installation Routine ---
    RunAs($sUserName, $sDomain, $sPassword, 0, $sAppPath)
    _Install("Expedite Bid 5.9a Setup", "The InstallShield Wi")
        Send("{ENTER}")
    _Install("Expedite Bid 5.9a Setup", "Please read the foll")
        Send("{ENTER}")
    _Install("Expedite Bid 5.9a Setup", "Setup will install E")
        Send("{TAB}{TAB}{ENTER}")
    _Install("Choose Folder", "Please select the in")
        Send("C:\Program Files\Expedite\5.9a{ENTER}")
    _Install("Expedite Bid 5.9a Setup", "Setup will install E")
        Send("{ENTER}")
    _Install("Expedite Bid 5.9a Setup", "Setup will add progr")
        Send("{ENTER}")
    _Install("Expedite Bid 5.9a Setup", "Setup has completed ")
        Send("{SPACE}{TAB}{ENTER}")
    #endregion --- Expedite Installation Routine ---

FileDelete("C:\Documents and Settings\All Users\Desktop\Expedite*.*")
Call("_LogFile")
#endregion --- Install ---

#region --- Logging ---
; This section checks to see if a log file already exists.  If it already exists it exits the script;
; if it does not already exist then it creates a log file in the network installation directory.
Func _LogFile()
    If FileExists($sLogFilesPath & @ComputerName & ".txt") Then
        Exit
    Else
        FileWriteLine($sLogFilesPath & @ComputerName & ".txt", "BidX 5.9a Installed")
        FileWriteLine($sLogFilesPath & @ComputerName & ".txt", "")
        FileWriteLine($sLogFilesPath & @ComputerName & ".txt", "Computer Name:  " & @ComputerName)
        FileWriteLine($sLogFilesPath & @ComputerName & ".txt", "User Name:  " & @UserName)
        FileWriteLine($sLogFilesPath & @ComputerName & ".txt", "Date:       " & @MON & "/" & @MDAY & "/" & @YEAR)
        FileWriteLine($sLogFilesPath & @ComputerName & ".txt", "Time:       " & @HOUR & ":" & @MIN)
    EndIf
EndFunc
#endregion --- Logging ---

Exit
#endregion --- BidX5.9a Installation Script ---

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

~

Edited by Mobius

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