Jump to content

Search the Community

Showing results for tags 'selfupdate'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 2 results

  1. Edit 2: Version 1.0.0.3 including View History of Changes function Edit 1: Amended source code on guinness advise (replacement of obsolete _Iif() ) Example of Auto Updating of a running script using Internet Web download. Works as well for compiled as for uncompiled scripts. Download with file size and checksum verification UpdateTest_1.0.1.3.au3 this is version 1.0.1.2 for the update example Helper to setup file data (version, date, filesize and CRC) in AppsUpdates.txt AppsUpdates_Calculator.au3 Credits: MsgBoxEx() used in in the example written by Ward _CRC32() also by Ward (just a coincidence) version 1.0.0.2: Before you test the script, compile it first with AutoIt3Wrapper, to get the version number in the executable. You can test it then with both compiled and uncompiled versions. The script example will check the application update version in file AppsUpdates.txt on the update website. If required, it will propose the upgrade. You can then disregard it or accept the update. The new 'View Changes' button will download and display the change information text. If updating, the initial script will be renamed with it's version number (as safety backup), and the new updated will be renamed to the initial script file name, in order not to break shortcuts. There is no code to postpone the update proposal by a number of days, this has to be programmed separately. Web data file AppsUpdates.txt content (INI file) now includes a new line containing the url to history file: changes=... [UpdateTest.au3] version=1.0.1.3 date=2014/06/26 23:00 Filesize=22234 CRC=77446F0C download=http://users.telenet.be/GreenCan/AutoIt/Updates/UpdateTest_1.0.1.3.au3 changes=http://users.telenet.be/GreenCan/AutoIt/Updates/UpdateTest_HistoryOfChanges.txt [UpdateTest.exe] version=1.0.1.3 date=2014/06/26 23:02 Filesize=490496 CRC=28974906 download=http://users.telenet.be/GreenCan/AutoIt/Updates/UpdateTest_1.0.1.3.exe changes=http://users.telenet.be/GreenCan/AutoIt/Updates/UpdateTest_HistoryOfChanges.txt The web directory has 3 files: AppsUpdates.txt (the updater data file) UpdateTest_1.0.1.1.exe UpdateTest_1.0.1.1.au3
  2. Include this script to your actual project and when SUP_Check() is called your script is going to download the next version and self update him self then restart. I am sorry but i did not bother to make a UDF or a more user friendly and flexible module since i still have a lot to go on my initial project 1- inside your project you include thoses line , all together and before your script actual code, beside your log system if you have one #include "self_update.au3" SUP_SetLogCallBack("_log") ; optional , used to send log to your allready log system if success self loggin is disable SUP_SetCheckCallBack("SUP_DownloadProgress") ; optional , will send the % of the download in progress SUP_Start("VALID HTTP URL To YPOUR NEW FILE","DOWNLOAD FULL FILE PATH NAME") ; mandatory 2- Now anywhere in your script you call this line to check for a newer version $fileVersionUrl: is if your using a custom web page to send fast information on the file like version that optional, if empty will always update when check $parentGui="": the self updated will create a gui with a progress bar and try to attach it self to the $parentGui , that optional SUP_Check($fileVersionUrl="",$parentGui="") 3- to check if your script has just restarted after a update if IsDeclared("updateComplete") then ConsoleWrite("Update Complete Sucess Bravo!") endif File: SUP_SelfUpdate.au3 The script can be compiled alone for debug purpose , look for 1 line to uncomment inside the script if running alone #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_outfile=e:SelfUpdate.exe #AutoIt3Wrapper_Change2CUI=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include-once ;*************** Line to be use inside your own project************ ; ;~ #include "self_update.au3" ;~ SUP_SetLogCallBack("_log") ;~ SUP_SetCheckCallBack("SUP_DownloadProgress") ;~ SUP_Start("e:SelfUpdate_FF.exe",@TempDir&"SelfUpdate_FF.exe") ; ;******************************************************************* Global $SUP_LOGS_CALL[1] = [0] Global $SUP_DOWN_CALL[1] = [0] Global $SUP_URL Global $SUP_FILE Global $SUP_INFO_FILE Global $SUP_DEST_FILE Global $SUP_PID ;**************Uncomment to self debug that script alone************* ;~ SUP_Start(@ScriptDir&"SelfUpdate.exe",@TempDir&"SelfUpdate.exe") ;******************************************************************** Func SUP_Start($SUPURL,$SUPFILE) $SUP_URL = $SUPURL $SUP_FILE = $SUPFILE $SUP_INFO_FILE = $SUP_FILE&".info" if $CmdLine[0] > 0 Then Switch $CmdLine[1] case "update" SUP_InitInfo() if Not ProcessWaitClose($SUP_PID,30) Then SUP_Log("UPDATE - Could not complete since """&$SUP_DEST_FILE&""" will not close",false) Exit EndIf if Not FileCopy($SUP_FILE,$SUP_DEST_FILE,1) Then SUP_Log("UPDATE - Could not copy the new file to """&$SUP_DEST_FILE&"""",false) Exit EndIf Run($SUP_DEST_FILE&" updatecomplete") exit case "updatecomplete" SUP_Delete() ;~ SUP_Log("UPDATE - Complete sucess") Assign("updateComplete",true,2) EndSwitch ;~ Else ;~ SUP_Check() ;for testing to be remove when linked with main EndIf ;~ sleep(5000) EndFunc Func SUP_InitInfo() local $data = FileRead($SUP_INFO_FILE) $data = StringSplit($data,"|") if $data[0] <> 2 Or $data[1]="" or $data[2] = "" Then SUP_Log("UPDATE - Info File is invalid") sleep(4000) exit EndIf $SUP_PID = $data[1] $SUP_DEST_FILE = $data[2] EndFunc Func SUP_Delete() FileDelete($SUP_FILE) FileDelete($SUP_INFO_FILE) EndFunc Func SUP_SetCheckCallBack($funcCallBack) ReDim $SUP_DOWN_CALL[$SUP_DOWN_CALL[0]+2] $SUP_DOWN_CALL[0] += 1 $SUP_DOWN_CALL[$SUP_DOWN_CALL[0]] = $funcCallBack EndFunc Func SUP_Check($fileVersionUrl="",$parentGui="") ;~ if $RUN then return local $version = FileGetVersion(@AutoItExe) local $nextVersion = "always update" if $fileVersionUrl <> "" Then $nextVersion = BinaryToString(InetRead($fileVersionUrl,1)) ;~ SUP_Log($version&" "&$nextVersion) if $nextVersion = "" Or $version = $nextVersion Then SUP_Log("UPDATE - No new version found") Return EndIf SUP_Log("UPDATE - New version found") SUP_Log("UPDATE - Downloading version "&$nextVersion) local $size = InetGetSize($SUP_URL,1) FileDelete($SUP_FILE) local $handle = InetGet($SUP_URL,$SUP_FILE,1,1) local $byteRead, $error = false #include <WindowsConstants.au3> GUICreate("ProgressBar",200,30,-1,-1,BitOR($WS_MINIMIZEBOX,$WS_DLGFRAME,$WS_POPUP,$WS_GROUP,$WS_CLIPSIBLINGS), BitOR($WS_EX_TOOLWINDOW,$WS_EX_TOPMOST),$parentGui) local $progress = GUICtrlCreateProgress(0,0,200,30) GUISetState(@SW_SHOW) local $pct do Sleep(250) $byteRead = InetGetInfo($handle, 0) if @error Then $error = true ExitLoop EndIf GUICtrlSetData($progress,$byteRead*100/$size) $pct = Round($byteRead*100/$size,2) SUP_Log("UPDATE - Percent done: "&$pct) If $SUP_DOWN_CALL[0] > 0 Then For $i = 1 to $SUP_DOWN_CALL[0] Call($SUP_DOWN_CALL[$i],$pct) Next EndIf Until InetGetInfo($handle, 2) GUIDelete() if $error or Not InetGetInfo($handle,3) Then InetClose($handle) SUP_Log("UPDATE - Downloading next version failed") SUP_Delete() Return EndIf InetClose($handle) FileDelete($SUP_INFO_FILE) FileWrite($SUP_INFO_FILE,@AutoItPID&"|"&@ScriptFullPath) SUP_Log("UPDATE - Exiting to complete update") Run($SUP_FILE&" update") if @error Then SUP_Log("UPDATE - Unable to open the new file") SUP_Delete() Return endif SUP_Log("UPDATE - Exiting") sleep(1000) Exit EndFunc Func SUP_SetLogCallBack($funcCallBack) ReDim $SUP_LOGS_CALL[$SUP_LOGS_CALL[0]+2] $SUP_LOGS_CALL[0] += 1 $SUP_LOGS_CALL[$SUP_LOGS_CALL[0]] = $funcCallBack EndFunc Func SUP_Log($msg,$useCallBack=true) If $useCallBack And $SUP_LOGS_CALL[0] > 0 Then For $i = 1 to $SUP_LOGS_CALL[0] Call($SUP_LOGS_CALL[$i],$msg) Next Return EndIf if @Compiled Then MsgBox(0,"Message",$msg) ConsoleWrite($msg&@CRLF) EndFunc
×
×
  • Create New...