Jump to content

My Sript


Recommended Posts

Hello,

Sorry for my language but i am french :(

I am trying to do an automatic update with this poor script :

#NoTrayIcon

#include <Inet.au3>

$size = InetGetSize("http://iportable.tuxfamily.org/dl/ClamWinPortable.exe")

$size1 = FileGetSize("ClamWinPortable.exe")

If $size = $size1 Then

Exit

endif

Else

InetGet("http://iportable.tuxfamily.org/dl/ClamWinPortable.exe", @DesktopDir & "\ClamWinPortable.exe", 1)

If InetGetSize = 0 Then

Sleep(10000)

Run("Myfile.exe")

endif

But it don't work very well :)

How can i do to release this ?

PS : i am beginner

THANKS

Link to comment
Share on other sites

try

#NoTrayIcon
#include <Inet.au3>

$size = InetGetSize("http://iportable.tuxfamily.org/dl/ClamWinPortable.exe")
$size1 = FileGetSize("ClamWinPortable.exe")

If $size = $size1 Then
    Exit
    
Else
    InetGet("http://iportable.tuxfamily.org/dl/ClamWinPortable.exe", @DesktopDir & "\ClamWinPortable.exe", 1)
    
    While @InetGetActive
        Sleep ( 1000 )
    WEnd
    Run("Myfile.exe")
        
EndIf
Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

Okay a few things... Welcome to the forums and AutoIt! Dont worry about your English. I get the meaning of what you are trying to convey.

Use [ code ] [ /code ] (without spaces) to encompass your code. Looks nicer and easier to read.

Now about your code.

You seem to want this to check every 10 seconds to see if there is a new version is this the case? If so why so often? I dont know of any software that checks for an update ever 10 seconds.

Is there a dat file that you can download and check version numbers? That is what we did her at AutoIt so we could include the AutoUpdateIt program. Look around there probably is a better way than checking size.

Study the below code. It only checks every 10 minutes, and should work out for you. You may want to consider getting SciTE it helps with formatting of AutoIt Scripts. It can be found at SciTE4AutoIt3.

#NoTrayIcon
; Press Esc to terminate script, Pause/Break to "pause"

Global $Paused
HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{ESC}", "Terminate")

Dim $minutes = 10
Dim $sleep = $minutes * 1000 * 60

While 1
    _UpdateCheck()
    Sleep($sleep)
WEnd

Func _UpdateCheck()
    $size = InetGetSize("http://iportable.tuxfamily.org/dl/ClamWinPortable.exe")
    $size1 = FileGetSize("ClamWinPortable.exe")

    If $size = $size1 Then
        Return
    Else
        InetGet("http://iportable.tuxfamily.org/dl/ClamWinPortable.exe", @DesktopDir & "\ClamWinPortable.exe", 1)
    EndIf
EndFunc

Func TogglePause()
    $Paused = NOT $Paused
    While $Paused
        sleep(100)
        ToolTip('Script is "Paused"',0,0)
    WEnd
    ToolTip("")
EndFunc

Func Terminate()
    Exit 0
EndFunc

I hope this helps you in your scripting endeavors.

Good luck and keep it fun!,

JS

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
Share on other sites

OK,

Thanks for your answer gafrost :)

But there's a problem : When the download finish, "autoit" want to run myfile.exe or i it is not the thing wanted.

In my idea, i would like : if the download is right, EXIT the program.

Do you understand me ?

Link to comment
Share on other sites

OK,

Thanks for your answer gafrost :)

But there's a problem : When the download finish, "autoit" want to run myfile.exe or i it is not the thing wanted.

In my idea, i would like : if the download is right, EXIT the program.

Do you understand me ?

sounds like you want to keep trying to you get a sucessful download then exit script

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

This will do what you are asking..

#NoTrayIcon
; Press Esc to terminate script, Pause/Break to "pause"

Global $Paused
HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{ESC}", "Terminate")

Dim $minutes = 1
Dim $sleep = $minutes * 1000 * 60

While 1
    _UpdateCheck()
    Sleep($sleep)
WEnd

Func _UpdateCheck()
    $size = InetGetSize("http://iportable.tuxfamily.org/dl/ClamWinPortable.exe")
    $size1 = FileGetSize("ClamWinPortable.exe")

    If $size = $size1 Then
        Return
    Else
        InetGet("http://iportable.tuxfamily.org/dl/ClamWinPortable.exe", @DesktopDir & "\ClamWinPortable.exe", 1)
        Terminate()
    EndIf
EndFunc

Func TogglePause()
    $Paused = NOT $Paused
    While $Paused
        sleep(100)
        ToolTip('Script is "Paused"',0,0)
    WEnd
    ToolTip("")
EndFunc

Func Terminate()
    Exit 0
EndFunc

This will check for the update every minute until it downloads it. You can stop it early by pressing ESC or Pause it by pressing PAUSE. NOTE: You cannot pause the actual download.

I hope this helps accomplish what you want,

JS

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

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...