Jump to content

IfFileDoesntExist


Recommended Posts

Hi Guys,

I want AutoIT to download FireFox if it doesn't already exist. I have the download part sorted, I just need the file check part; here is what I have so far:

Local $hFirefox = InetGet("http://download.mozilla.org/?product=firefox-3.6.8&os=win&lang=en-GB", "C:\Firefox.exe", 1, 1)
do
    sleep(500)
Until InetGetInfo($hFirefox, 2)
InetClose($hFirefox)
FileMove("C:\Firefox.exe",$path & "\Tools\Firefox.exe", 9)
sleep(100)
ShellExecute($path & "\Tools\Firefox.exe")

So I need to add something like:

If FileDoesn'tExist (@ProgramFilesDir & "\Mozilla Firefox\firefox.exe") Then

But not sure on the function - if there is one??

Oh, and just to make it neater any help on why I can't use InetGet to download direct to $path\tools would be great - no error, code processes, just file doesn't appear (anywhere on HDD - searched for it!)

All help is much appreciated,

Thanks

Andy

Edited by 3mustgetbeers
Link to comment
Share on other sites

Would this work??

If FileExists (@ProgramFilesDir & "\Mozilla Firefox\firefox.exe") Then
    Sleep(1)
Else

Local $hFirefox = InetGet("http://download.mozilla.org/?product=firefox-3.6.8&os=win&lang=en-GB", "C:\Firefox.exe", 1, 1)
do
    sleep(500)
Until InetGetInfo($hFirefox, 2)
InetClose($hFirefox)
FileMove("C:\Firefox.exe",$path & "\Tools\Firefox.exe", 9)
sleep(100)
ShellExecute($path & "\Tools\Firefox.exe")
EndIf

Thanks!!

Link to comment
Share on other sites

There is one certain way to find out if it will work, and thats try it.

;your code...
If Not FileExists($file) Then
   _DownloadFileFunc()
EndIf
;the rest of your code

Ahhhhh! I didn't think about the NOT operator! Cheers mate, works a treat - and looks tidier than having it sleep.

Thanks alot!

Link to comment
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
 Share

  • Recently Browsing   0 members

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