Sign in to follow this  
Followers 0
3mustgetbeers

IfFileDoesntExist

7 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites



Just to add to that; the function is within a Case, so if there is a way to write

If FileExsits (firefox) Then
  Crack on!
Else
  (download FireFox)

??

Thanks again!

Share this post


Link to post
Share on other sites

PsaltyDS:

The path is earlier in the script;

$path = @ProgramFilesDir & "\Andys Little Tool\"

Thanks

Andy!

Share this post


Link to post
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!!

Share this post


Link to post
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!

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