Jump to content



Photo

Auto Updater


  • Please log in to reply
4 replies to this topic

#1 zone97

zone97

    Seeker

  • Active Members
  • 45 posts

Posted 16 April 2008 - 10:16 PM

Here is the auto updater I created. This program reads a version.ini file and compares it to a current.ini file and if the new version# is greater, it downloads the update and closes the existing program and launches the new version. This works good for a few minutes then stops doing what it is designed to? It is not crashing, just not checking for the version.ini any longer. The webserver does not register any hits after a certain amount of time. It has no gui, just a tray icon, clicking the icon closes the app, you can also do a CTRL-ALT-X.

Could someone please look this over and point out anything that could be done better, or why it may be stop responding?

Thanks.

** the web server has been changed to protect the innocent. **

AutoIt         
#NoTrayIcon #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_icon=promon_u.ico #AutoIt3Wrapper_UseAnsi=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** ;############################################################################## ;# Options HotKeySet("^!x","quit") #include <GuiConstants.au3> #include <Constants.au3> #include <inet.au3> Opt("TrayOnEventMode", 1) Opt("TrayMenuMode", 1) Opt("WinWaitDelay", 750) TraySetIcon("promon_u.ico") TraySetOnEvent($TRAY_EVENT_PRIMARYUP, "SpecialEvent") ;############################################################################## ;# GUI Form Information GUISetState() ;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ;@ Program Start While 1     checkver() WEnd ;############################################################################## ;# Functions ; FUNC: Minimize to tray. Func SpecialEvent()     Exit EndFunc ; FUNC: Check version Func checkver()     FileDelete("version.ini")     Sleep(250)     InetGet("<a href='http://mywebserver.com/version.ini' class='bbc_url' title='External link' rel='nofollow external'>http://mywebserver.com/version.ini"</a>, @ScriptDir & "\version.ini", 1, 0)     Sleep(1000)     $version1 = IniRead("current.ini", "version", "version", "")     $version2 = IniRead("version.ini", "version", "version", "")     if $version1 < $version2 Then update()     Sleep(1000) EndFunc ; FUNC: Update the software Func update()     $FileURL = "<a href='http://mywebserver.com/promon.exe' class='bbc_url' title='External link' rel='nofollow external'>http://mywebserver.com/promon.exe"</a>     $FileName = "promon_new.exe"     $FileSize = InetGetSize($FileURL)     InetGet($FileURL,$FileName,0,1)     ProgressOn("Progress Meter", "Increments every second", "0 percent")     While @InetGetActive         $Percentage = @InetGetBytesRead * 100 / $FileSize         ProgressSet($Percentage,"Downloaded " & @InetGetBytesRead & " of " & $FileSize & " bytes","Downloading " & $FileName)         Sleep(250)     Wend     ProgressOff()       WinClose("Process Monitor","")     Sleep(2000)     FileCopy("version.ini","current.ini",1)     FileCopy(@ScriptDir & "\promon_new.exe",@ScriptDir & "\promon.exe",1)     FileDelete(@ScriptDir & "\promon_new.exe")     Run(@ScriptDir & "\promon.exe")     Sleep(2000)     ControlClick("Process Monitor","","Button1","Left",1) EndFunc Func quit()     Exit EndFunc






#2 Swift

Swift

    Get Linux Ubuntu Now.

  • Banned (NOT IN USE)
  • 1,706 posts

Posted 16 April 2008 - 10:29 PM

1) It Burns CPU
2) Don't Use The InetGet() Use a _IE* function to read the page.. (much faster),
3)_VersionCompare() To compare the files...
4) If using version compare...dont use a .ini..use a fileread...and etc...

Just some things I saw..

#3 zone97

zone97

    Seeker

  • Active Members
  • 45 posts

Posted 17 April 2008 - 12:56 AM

1) It Burns CPU
2) Don't Use The InetGet() Use a _IE* function to read the page.. (much faster),
3)_VersionCompare() To compare the files...
4) If using version compare...dont use a .ini..use a fileread...and etc...

Just some things I saw..


When you say burn CPU do you mean cause its working all the time? Im not objectionable to a timer, however I do not really like the sleep function because it prevents the application from responding to a close request.

i'm new to autoit, could you show me how those items you suggested work?

Thanks.

#4 Swift

Swift

    Get Linux Ubuntu Now.

  • Banned (NOT IN USE)
  • 1,706 posts

Posted 17 April 2008 - 01:29 AM

Put a Sleep(50) in there, it will not seem to slow it down, but it stops the burn of CPU.

_VersionCompare() It's in the Misc.au3 file.
_InetGetSource() might be what you need or use a _IE* function to read the txt without downloading it.

And use FileWrite, FileRead, FileReadLine() Etc. to see the actual version without using a .ini

#5 zone97

zone97

    Seeker

  • Active Members
  • 45 posts

Posted 17 April 2008 - 02:12 AM

Put a Sleep(50) in there, it will not seem to slow it down, but it stops the burn of CPU.

_VersionCompare() It's in the Misc.au3 file.
_InetGetSource() might be what you need or use a _IE* function to read the txt without downloading it.

And use FileWrite, FileRead, FileReadLine() Etc. to see the actual version without using a .ini

There is 2.25 seconds of sleep time durring the main function of looking at the version info? Does it need more?

could you do something like..

for x$ 1 to 120 sleep(1000) ** do soemthing here to still listen for keyboard commands. next


that way you sleep for 1 second at a time for 120 seconds while still responding to mouse clicks and such?

also checked the logs, it seems to work for around 30 - 35 minutes before stopping? any clue?

Edited by zone97, 17 April 2008 - 02:14 AM.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users