Jump to content

Recommended Posts

Posted (edited)

If FileExists("C:\Program Files\Java\jre8\bin\java.exe") Then
    $appway = "C:\Program Files\Java\jre8\bin"
    $exeway = "C:\Program Files\Java\jre8\bin\java.exe"
ElseIf FileExists("C:\Program Files (x86)\Java\jre8\bin\java.exe") Then
    $appway = "C:\Program Files (x86)\Java\jre8\bin"
    $exeway = "C:\Program Files (x86)\Java\jre8\bin\java.exe"
EndIf


If FileExists($exeway) Then
    MsgBox(0, "Java", "Installation Complete", 5)
Else
    MsgBox(0, "Java", "Installation Fail !", 5)
EndIf

it works if file exist in destination folder but if file not exit in destination folder it doesn't say "Installatiion fail" with msgbox.

Edited by bordomavi
Posted (edited)

I think Your scirpt work correctly EDIT: in my case.

What you want to achieve ?

btw.

you can use @ProgramFilesDir

edit2:

where you declaring this variable ? check my first two lines:

Local $appway = ''
Local $exeway = ''
If FileExists("C:\Program Files\Java\jre8\bin\java.exe") Then
    $appway = "C:\Program Files\Java\jre8\bin"
    $exeway = "C:\Program Files\Java\jre8\bin\java.exe"
ElseIf FileExists("C:\Program Files (x86)\Java\jre8\bin\java.exe") Then
    $appway = "C:\Program Files (x86)\Java\jre8\bin"
    $exeway = "C:\Program Files (x86)\Java\jre8\bin\java.exe"
EndIf


If FileExists($exeway) Then
    MsgBox(0, "Java", "Installation Complete", 5)
Else
    MsgBox(0, "Java", "Installation Fail !", 5)
EndIf
Edited by mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

Well, in your code you have two possible cases :

 - FileExists ("C:Program FilesJavajre8binjava.exe")

 - FileExists ("C:Program Files (x86)Javajre8binjava.exe")

But what about the case where neither of these two cases matches ?

You should add a Else

If FileExists("C:\Program Files\Java\jre8\bin\java.exe") Then
    $appway = "C:\Program Files\Java\jre8\bin"
    $exeway = "C:\Program Files\Java\jre8\bin\java.exe"
ElseIf FileExists("C:\Program Files (x86)\Java\jre8\bin\java.exe") Then
    $appway = "C:\Program Files (x86)\Java\jre8\bin"
    $exeway = "C:\Program Files (x86)\Java\jre8\bin\java.exe"
Else
    $exeway = ""
EndIf

or just declare an empty variable before the condition : Local $exeway

Posted
  On 8/19/2014 at 8:24 PM, mLipok said:

 

I think Your scirpt work correctly EDIT: in my case.

What you want to achieve ?

btw.

you can use @ProgramFilesDir

edit2:

where you declaring this variable ? check my first two lines:

Local $appway = ''
Local $exeway = ''
If FileExists("C:\Program Files\Java\jre8\bin\java.exe") Then
    $appway = "C:\Program Files\Java\jre8\bin"
    $exeway = "C:\Program Files\Java\jre8\bin\java.exe"
ElseIf FileExists("C:\Program Files (x86)\Java\jre8\bin\java.exe") Then
    $appway = "C:\Program Files (x86)\Java\jre8\bin"
    $exeway = "C:\Program Files (x86)\Java\jre8\bin\java.exe"
EndIf


If FileExists($exeway) Then
    MsgBox(0, "Java", "Installation Complete", 5)
Else
    MsgBox(0, "Java", "Installation Fail !", 5)
EndIf

yes but some programs use "program files" folder in 64 bit systems. these must use "program files x86"

Posted

so the problem was : not setting initial value.

but you have not any errors ?

This was a first what I see in my SciTE4AutoIt console when I run your script:

>"C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "Z:\TOOLS\Macro\PROGRAMY\test_FileExist.au3" /UserParams    
+>22:38:16 Starting AutoIt3Wrapper v.14.801.2025.0 SciTE v.3.4.4.0   Keyboard:00000415  OS:WIN_7/Service Pack 1  CPU:X64 OS:X64    Environment(Language:0415)
+>         SciTEDir => C:\Program Files (x86)\AutoIt3\SciTE   UserDir => C:\Users\user\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper   SCITE_USERHOME => C:\Users\user\AppData\Local\AutoIt v3\SciTE 
>Running AU3Check (3.3.13.0)  from:C:\Program Files (x86)\AutoIt3  input:Z:\TOOLS\Macro\PROGRAMY\test_FileExist.au3
+>22:38:16 AU3Check ended.rc:0
>Running:(3.3.10.2):C:\Program Files (x86)\AutoIt3\autoit3.exe "Z:\TOOLS\Macro\PROGRAMY\test_FileExist.au3"    
--> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop
"Z:\TOOLS\Macro\PROGRAMY\test_FileExist.au3" (11) : ==> Variable used without being declared.:
If FileExists($exeway) Then
If FileExists(^ ERROR
->22:38:16 AutoIt3.exe ended.rc:1
+>22:38:16 AutoIt3Wrapper Finished.
>Exit code: 1    Time: 0.4234

I mean:

"Variable used without being declared.:"

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

Basically, the question boils down to: Are you using SciTE4AutoIt ?

https://www.autoitscript.com/site/autoit-script-editor/

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...