Sign in to follow this  
Followers 0
=sinister=

AutoUpdate

20 posts in this topic

#1 ·  Posted (edited)

Auto Updater

Completley Rewritten and Partly Tested!

Put this code at the top of your script and edit it to your needs-

local const $Version = "1.1"
local const $Data = "C:\temp\updater.dat"
local const $Website = "http://www.myclanhosting.com/AutoUpdater/update.ini"
local const $Website_Update = "www.yourdomain.com/updates"
local const $Days = 7
local const $Script = @ScriptDir & "\file.exe"
local const $Internet = "3.0"
local const $i_OPT = 2
local const $error = @error = 0
local $old, $diff, $message
if not(fileExists($Data)) then
fileWrite($Data, @YDAY)
else
$old = fileReadLine($Data, 1)
if ($old >= (365 - $Days)) then
fileDelete($Data)
return
endIf
$diff = @YDAY - $old
if ($diff >= $Days) Then
$message = MsgBox(0x44, "Notification", "Your last update was more than " & $diff & " days ago." & @LF & "Would you like to check for updates?")
If ($message = 6) Then $IEVersion = RegRead ( "HKLM\SOFTWARE\Microsoft\Internet Explorer" , "Version" )
If $IEVersion = "" Then MsgBox ( 16 , "Error" , "Unable to read Internet version." )
If $IEVersion <= $Internet Then 
    MsgBox ( 16 , "Error" , "Unable to update file, please manually check." )
$Ping = Ping($Website, 4000)
If @error = 0 Then 
_INetBrowse($Website_Update, $i_OPT = 1)    
Else 
Msgbox(16,"Error","Unable to connect.")
EndIf
EndIf
EndIf
If ($diff >= $Days) And $IEVersion >= $Internet Then
    InetGet($Website, "C:\temp\update.ini", 1)
$Update = IniRead("C:\temp\update.ini", "Update", "Update", "NotFound") 
if $Update >= $Version then
$Scite = IniRead("C:\temp\update.ini", "Update", "Site", "NotFound")
If $Update = $Version Then
MsgBox(1, "Information", "There are no updates.")
EndIf
        FileDelete($Script)
InetGet($Scite, "C:\file.exe")
If @error = 0 Then
fileDelete($Data)
fileWrite($Data, @YDAY)
    Else
    Msgbox(16,"Error","Unable to update software.")
    EndIf
EndIf
EndIf
Endif
Func _INetBrowse($Website_Updater, $i_OPT = 2)
Switch $i_OPT
Case 0
RunWait(@comspec & ' /c start ' & $Website_Update, @WorkingDir, @SW_HIDE)
return 1
Case 1
RunWait("rundll32.exe url.dll,FileProtocolHandler " & $Website_Update, @WorkingDir)
Return 1
Case 2
DllCall("Shell32.dll", "int", "ShellExecute", "hwnd", 0, "str", 'open', "str", $Website_Update, "str", '', "str", @WorkingDir, "int", 10)
return 1
Case 3
$o_SA = ObjCreate('Shell.Application')
$o_SA.Open($Website_Updater)
return 1
EndSwitch
Return 0
EndFunc

It will check for updates every 7 days by downloading an ini from a website. The ini should look like this-

[Update]
Update=1.1
Scite=www.mydomain.com/file.exe

If you want to update the file, upload the file to the correct directory and change the version to a higher one. Also, if the user doesn't have Internet Explorer V3.0 or higher, it will take the user to the Update Page which you should have on your website.

Edited by =sinister=

Share this post


Link to post
Share on other sites



Sad, over 100 views and no posts, :o

Share this post


Link to post
Share on other sites

Nice script. Mine is a little like it, although yours doesn't look so cluttered :o


Ha, I haven't been on these forums since... 2006, almost. Behold, my legacy signature:My AutoIt idol is Valuater. You know you love him, too.My Stuff: D&D AGoT Tools Suite

Share this post


Link to post
Share on other sites

Um, have you actually tested this with two different versions of your exe file? You may have problems deleting yourself while you are running. I see you are not testing for error codes that may assist with program success...

Does "free" websites include the time to remove spyware and advertising?

Share this post


Link to post
Share on other sites

Hey man, chill out. You sound like you have PMS.


Ha, I haven't been on these forums since... 2006, almost. Behold, my legacy signature:My AutoIt idol is Valuater. You know you love him, too.My Stuff: D&D AGoT Tools Suite

Share this post


Link to post
Share on other sites

Hey man, chill out. You sound like you have PMS.

Yeah - Programming Maintenance Syndrome! :o

Share this post


Link to post
Share on other sites

freewebs doesn't have any adds... I think cjb does though...

Share this post


Link to post
Share on other sites

Almost 300 views and only 7 replies?! That makes me more sad..

Share this post


Link to post
Share on other sites

you should really check your code for errors, i can see errors. Like $update, Theres no '=' Sign.


[size=20]My File Upload[/size]Register at my site and upload.

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

Just because nobody has replyed to something you have said dosn't mean you have not made something good. Don't let the number of replys get you down.

As for the script. Instead of having the .ini file say 'yes' to there being an update, have the .ini display a version number, date, or something. What happenes when there is an update? You get it and the next time you check there is newer version but it still has to say yes because there is an update from the original. If you wanted to. You could also have the .ini file carry a hash of somekind to confirm the download.

[edit]

Ok, now that I have taken a good look at the script I have a few things to say.

Line 1

Why not just use an ini?

Line 6 & 7

After it writes the year to a dat file, it skips everything and looks for an ini on the C:.

Line 10

It looks to make sure there are no bugs when it comes to checking how many days it has been since the last check but deleteing the file is not going to fix anything.

Line 12

The 'return' keyword is only used in functions I believe.

Line 19

Why not download to a temp folder so the C:'s root dir stays clean.

Line 25

As was previously pointed out, there is a missing '=' sign.

Line 27

You set it to return "Not Found" if the ini read failed but you didn't have autoit handle it any differetly then it would handle if it had found it. So you end up looking for a webpage at the site "Not Found".

Edited by gamerman2360

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

Also, dont use if Not FileExists(blah), Because once it gets it, And run the script again, it doesnt get the New .ini since theres already one.

Just take out the if Not File etc etc..:o.

Local $ini = 'http://www.mywebsite.com/mysite/myini.ini
INetGet($ini,'C:\Update.ini')

So When it gets executed, it gets the Ini File.

Edited by NegativeNrG

[size=20]My File Upload[/size]Register at my site and upload.

Share this post


Link to post
Share on other sites

I like your update script but use <= instead of < to check if the latest is installed


My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

Ok, I rewrote the whole script,

Thanks to:

W0uter for the INetBrowse

Tmakruck for the Internet Version Checker

I'll be updating this more often, mostly deleting bugs.

Note: It's only been partically tested because I don't have FireFox so if the errors don't work, don't be suprised, but im pretty sure they work.

Edited by =sinister=

Share this post


Link to post
Share on other sites

heaps better! :)

Just a suggestion, why not update it by the File Version. Don't Use 'Yes' And 'no' Because If the user who already updated it, and wants to update it again(to see if theres another update), will download the file AGAIN, therefore wasting Space/Download limit.


[size=20]My File Upload[/size]Register at my site and upload.

Share this post


Link to post
Share on other sites

added the Version Checker. Not tested so it might not work, don't know.

Share this post


Link to post
Share on other sites

Updated twice in 1 day, sweet.

Updates:

-Fixed Bug

-Files now go to \Temp

-Checks for Errors

-If there are no updates, It will say so

Share this post


Link to post
Share on other sites

i have made my own updater, but could you please host an example file that uses yours so i can see it?


My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.

Share this post


Link to post
Share on other sites

I found about 93745384024 bugs in the script, so I was editing it for about 30 min. This one will show you a little taste of my updater:

local const $Version = "1.6"
local const $Data = "C:\temp\updater.dat"
local const $Website = "http://www.myclanhosting.com/AutoUpdater/update.ini"
local const $Website_Update = "www.yourdomain.com/updates"
local const $exe = "/file.exe"
local const $Days = 7
local const $Script = @ScriptDir & "\file.exe"
local const $Internet = "3.0"
local const $i_OPT = 2
local const $error = @error = 0
local $old, $diff, $message
if not(fileExists($Data)) then
fileWrite($Data, @YDAY)
else
$old = fileReadLine($Data, 1)
if ($old >= (365 - $Days)) then
fileDelete($Data)
return
endIf
$diff = @YDAY - $old
if ($diff >= $Days) Then
$message = MsgBox(0x44, "Notification", "Your last update was more than " & $diff & " days ago." & @LF & "Would you like to check for updates?")
If ($message = 6) Then $IEVersion = RegRead ( "HKLM\SOFTWARE\Microsoft\Internet Explorer" , "Version" )
If $IEVersion = "" Then MsgBox ( 16 , "Error" , "Unable to read Internet version." )
If $IEVersion <= $Internet Then 
    MsgBox ( 16 , "Error" , "Unable to update file, please manually check." )
$Ping = Ping($Website, 4000)
If @error = 0 Then 
_INetBrowse($Website_Update, $i_OPT = 1)    
Else 
Msgbox(16,"Error","Unable to connect.")
EndIf
EndIf
EndIf
If ($diff >= $Days) And $IEVersion >= $Internet Then
    InetGet($Website, "C:\temp\update.ini", 1)
$Update = IniRead("C:\temp\update.ini", "Update", "Update", "NotFound") 
$Domain = "http://www.myclanhosting.com/AutoUpdater/" & $Update & "/" & $exe
if $Update >= $Version then
If $Update = $Version Then
MsgBox(1, "Information", "There are no updates.")
EndIf
        FileDelete($Script)
InetGet($domain, "C:\file.exe")
fileDelete($Data)
fileWrite($Data, @YDAY)
If @error = 0 Then
Else
    
    Msgbox(16,"Error","Unable to update software.")
    Endif
EndIf
EndIf
Endif
Func _INetBrowse($Website_Updater, $i_OPT = 2)
Switch $i_OPT
Case 0
RunWait(@comspec & ' /c start ' & $Website_Update, @WorkingDir, @SW_HIDE)
return 1
Case 1
RunWait("rundll32.exe url.dll,FileProtocolHandler " & $Website_Update, @WorkingDir)
Return 1
Case 2
DllCall("Shell32.dll", "int", "ShellExecute", "hwnd", 0, "str", 'open', "str", $Website_Update, "str", '', "str", @WorkingDir, "int", 10)
return 1
Case 3
$o_SA = ObjCreate('Shell.Application')
$o_SA.Open($Website_Updater)
return 1
EndSwitch
Return 0
EndFunc

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