Sign in to follow this  
Followers 0
TheOnlyOne

My own updater

14 posts in this topic

hey

okay i got a script where it should check about there is any updates

if there are it should open my update program where i can set in files from my own computer on some way?

i looked on tcpsend in the help file but cant really understand how i can send a file ?

(:

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Just wrote this last night...

If @Compiled = 1 And InetGet("www.clicktask.com/files/myupdateversionfilewithoneline.txt", "XSkinUpdate.txt") Then
    If Number(FileReadLine("XSkinUpdate.txt")) > Number(FileGetVersion(@ScriptName)) Then
        ; do your update
    EndIf
EndIf

*** NOT TESTED

8)

Just open some free account ( there are many) and place your files on it, no need to build the site.

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites

can you explain more what this do :S?

Share this post


Link to post
Share on other sites

I'll explain his code and method. I'm just going to explain everything as i don't know how much you know about autoit and it could help someone else in the future.

If @Compiled = 1 And InetGet("www.clicktask.com/files/myupdateversionfilewithoneline.txt", "XSkinUpdate.txt") Then
    If Number(FileReadLine("XSkinUpdate.txt")) > Number(FileGetVersion(@ScriptName)) Then
        ; do your update
    EndIf
EndIf

Line 1 first checks if the script is compiled as an exe, then downloads a small text file from your website, as specified in teh InetGet function, that contains one line reading something like "1.1.0.0". The InerGet returns 1 if it successfully downloads the file, so having this in the if condition makes sure that the file was downloaded before updating.

Line 2 checks if the number in the file is greater than the current version of the script which is running, and if it it is, then it will run the part of code which he has missed out, which will be downloading the update from your website and saving it in place of the old one. The old version cannot be running when you save over it though.

I'll try and find my updater script and post it here later if you want a working tested one.

Share this post


Link to post
Share on other sites

I'll explain his code and method. I'm just going to explain everything as i don't know how much you know about autoit and it could help someone else in the future.

If @Compiled = 1 And InetGet("www.clicktask.com/files/myupdateversionfilewithoneline.txt", "XSkinUpdate.txt") Then
    If Number(FileReadLine("XSkinUpdate.txt")) > Number(FileGetVersion(@ScriptName)) Then
        ; do your update
    EndIf
EndIf

Line 1 first checks if the script is compiled as an exe, then downloads a small text file from your website, as specified in teh InetGet function, that contains one line reading something like "1.1.0.0". The InerGet returns 1 if it successfully downloads the file, so having this in the if condition makes sure that the file was downloaded before updating.

Line 2 checks if the number in the file is greater than the current version of the script which is running, and if it it is, then it will run the part of code which he has missed out, which will be downloading the update from your website and saving it in place of the old one. The old version cannot be running when you save over it though.

I'll try and find my updater script and post it here later if you want a working tested one.

Thank you for the explanation. I'm not the OP, but this helped me. So, how would you go about updating?

Would you have to run a seperate updater program?


Global $arr[2]

$arr[0]="hip"
$arr[1]="hip"
;^^ hip hip array. ^^

Share this post


Link to post
Share on other sites

There are several ways to do this. One way would be for the main script to check if an update is availaible right at the beginning, and if there is, to run a seperate script that does the updating then exit. The update script would then use InetGet to download the specified file(s) (if there is only one file in your program, this will be easy) from your website, and to overwrite the old compiled script with the new one. You'd prob want the update script to wait untill the old one has ended before updating, just incase.

sorry if that didn't help, but i'm in a slight rush... as i said, i'll look for my update script later and post it.

Share this post


Link to post
Share on other sites

Good explanation Rabbit!!

for me, The main script checks for an update, if approved by the user, the main script calls the update script. The update script downloads the new program and closes the main script. The the updater runs the installer included in the download.

... I think.... :)

lol

Valuater

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

yeahh, that's similar to mine, except mine just replaces files...

I found a very simple one i made when i started learning autoit, so it may not work/be up to scratch...:

;param1 current version             0.9.0.0
;param2 webserver                   http://www.website.com/script/
;param3 files to be updated         script.exe|icon.ico|background.bmp
;param4 exe to be run after update  script.exe

If $CmdLine[0] => 3 Then
    If StringRight($CmdLine[2],1) <> "\" AND StringRight($CmdLine[2],1) <> "/" Then $CmdLine[2] = $CmdLine[2]&"/"
    If _UpdateCheckAvailability($CmdLine[2]&"NewestVersion",$CmdLine[1])
    _UpdateFiles($CmdLine[2],$CmdLine[3])
    Else
        Msgbox(4096,"Update Failed","Incorrect number of parameters")
    EndIf
EndIf

If $CmdLine[0] => 4 Then Run($CmdLine[4])



Func _UpdateCheckAvailability($webfile = "",$currentver = "")
    If InetGet($webfile,"NewestVersion",1) AND $currentver <> "" Then
        If Number(FileReadLine("NewestVersion")) > Number($currentver) Then
            Return "1"
        Else
            Return "0"
        EndIf
        FileDelete("NewestVersion")
    Else
        SetError(1)
    EndIf
EndFunc


Func _UpdateFiles($scriptfol = "",$files = "")
    $filenames = StringSplit($files,"|")
    For $i = 1 to $filenames[0]
        SetError(NOT InetGet($scriptfol&$filenames[$i],$filenames[$i],1),$filenames[$i])
    Next
EndFuncoÝ÷ Ù±!=ÿnØ^~îûçn¦Øb±¸­² ¶[jÈjYr¶ºg­¸­{^¦è½ç(uçhzÉ÷öÜ(®K(fzØb²&¦½êò¶*ÞvÊ-êÞÊh­¶&¦¹È[^¯²¡÷hx"·br(ê'yélyƧ¦-méhÁ©Ý©çÞz[-ºjwbq©Þv+bµ«­¢+ÙÕ¹}UÁÑ
¡­Ù¥±¥±¥Ñä ÀÌØíÝ¥±ôÅÕ½ÐìÅÕ½Ðì°ÀÌØíÕÉɹÑÙÈôÅÕ½ÐìÅÕ½Ðì¤(%%%¹ÑÐ ÀÌØíÝ¥±°ÅÕ½Ðí9ÝÍÑYÉÍ¥½¸ÅÕ½Ðì°Ä¤9ÀÌØíÕÉɹÑÙȱÐìÐìÅÕ½ÐìÅÕ½ÐìQ¡¸($$ÀÌØí¹ÝÙÈôMÑÉ¥¹MÁ±¥Ð¡¥±I1¥¹ ÅÕ½Ðí9ÝÍÑYÉÍ¥½¸ÅÕ½Ð줰ÅÕ½Ðì¸ÅÕ½Ðì¤($$ÀÌØí½±ÙÈôMÑÉ¥¹MÁ±¥Ð ÀÌØíÕÉɹÑÙÈ°ÅÕ½Ðì¸ÅÕ½Ðì¤($%%ÀÌØí¹ÝÙÉlÅtÐìÀÌØí½±ÙÉlÅtQ¡¸($$%IÑÕɸÅÕ½ÐìÄÅÕ½Ðì($%±Í%ÀÌØí¹ÝÙÉlÅtôÀÌØí½±ÙÉlÅtQ¡¸($$%%ÀÌØí¹ÝÙÉlÉtÐìÀÌØí½±ÙÉlÉtQ¡¸($$%IÑÕɸÅÕ½ÐìÄÅÕ½Ðì($$%±Í%ÀÌØí¹ÝÙÉlÉtôÀÌØí½±ÙÉlÉtQ¡¸($$$%%ÀÌØí¹ÝÙÉlÍtÐìÀÌØí½±ÙÉlÍtQ¡¸($$$%IÑÕɸÅÕ½ÐìÄÅÕ½Ðì($$$%±Í%ÀÌØí¹ÝÙÉlÍtôÀÌØí½±ÙÉlÍtQ¡¸($$$$%%ÀÌØí¹ÝÙÉlÑtÐìÀÌØí½±ÙÉlÑtQ¡¸($$$$%IÑÕɸÅÕ½ÐìÄÅÕ½Ðì($$$$%±Í($$$$%IÑÕɸ($$$$%¹%($$$%¹%($$%¹%($%¹%($%¥±±Ñ ÅÕ½Ðí9ÝÍÑYÉÍ¥½¸ÅÕ½Ðì¤(%±Í($%MÑÉÉ½È Ä¤(%¹%)¹Õ¹

There HAS to be a better way than that... someone who isn't so tired must have just looked at that and thought "wtf was he thinking? It's obviously...", so post here if you have an idea...

Edited by rabbitkillrun

Share this post


Link to post
Share on other sites

can't edit that last post because it keeps coming up as random characters in the edit box, so sorry with the new post and terrible spelling in the last one...

@Valuater, my update thing could also be used to run an installer after download, i just noticed...

but Number() only returns the number before the first ".", so it doesn't work for comparing things, so i tried to make a way of comparing them, but it contains ALOT fo Ifs and ElseIfs, so any idea how to fix that into something a bit simpler...?

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

If $CmdLine[0] => 3 Then
    If StringRight($CmdLine[2],1) <> "\" AND StringRight($CmdLine[2],1) <> "/" Then $CmdLine[2] = $CmdLine[2]&"/"
    If _UpdateCheckAvailability($CmdLine[2]&"0.0.0.1",$CmdLine[1]) then
    _UpdateFiles($CmdLine[2],$CmdLine[3])
    Else
        Msgbox(4096,"Update Failed","Incorrect number of parameters")
    EndIf
EndIf

If $CmdLine[0] => 4 Then Run($CmdLine[4])



Func _UpdateCheckAvailability($webfile = "http://www.megaupload.com/?d=REN7YI3B",$currentver = "0.0.0.0")
    If InetGet($webfile,"0.0.0.1",1) AND $currentver <> "" Then
        $newver = StringSplit(FileReadLine("0.0.0.1"),".")
        $oldver = StringSplit($currentver,"0.0.0.0")
        If $newver[1] > $oldver[1] Then
            Return "1"
        ElseIf $newver[1] = $oldver[1] Then
            If $newver[2] > $oldver[2] Then
            Return "1"
            ElseIf $newver[2] = $oldver[2] Then
                If $newver[3] > $oldver[3] Then
                Return "1"
                ElseIf $newver[3] = $oldver[3] Then
                    If $newver[4] > $oldver[4] Then
                    Return "1"
                    Else
                    Return
                    EndIf
                EndIf
            EndIf
        EndIf
        FileDelete("0.0.0.1")
    Else
        SetError(1)
    EndIf
EndFunc


Func _UpdateFiles($scriptfol = @ScriptDir,$files = "MafiaWars Bot")
    $filenames = StringSplit($files,"|")
    For $i = 1 to $filenames[0]
        SetError(NOT InetGet($scriptfol&$filenames[$i],$filenames[$i],1),$filenames[$i])
    Next
EndFunc

i get one mistake (cant se about i made any others)

C:\Documents and Settings\lo\Skrivebord\mafia wars bot\Ny AutoIt v3 Script.au3(7,17) : ERROR: syntax error
If $CmdLine[0] =>
~~~~~~~~~~~~~~~~^
C:\Documents and Settings\lo\Skrivebord\mafia wars bot\Ny AutoIt v3 Script.au3(16,17) : ERROR: syntax error
If $CmdLine[0] =>

why that?

and someone plz explain me what $cmd does?

Edited by TheOnlyOne

Share this post


Link to post
Share on other sites

all mine have been integrated in my scripts so i can't find a sperate script... lol...

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