Jump to content

Recommended Posts

Posted

I'm trying to make a script that will autoupdate a self-made program from internet.

it should check the creation day an if it's newer download and install.

Any ideas?

Thnx

Posted

I'm trying to make a script that will autoupdate a self-made program from internet.

it should check the creation day an if it's newer download and install.

Any ideas?

Thnx

<{POST_SNAPBACK}>

Is the file that has to be downloaded on an ftp server? Is it always in the same location? Does the file name change or just the date?
...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format
Posted

It will be allways in the same location, it is http aviable, and the name should not be changed

Darkonen- take a look in the help file for InetGetSize, FileGetSize, and InetGet

Do a compare of the file sizes and, if different, get the file.

When you get some basic code down, post it here and everyone can offer more suggestions.

...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format
Posted (edited)

I have something that presently does this, entirely possible this isn't the most well implemented, but here's what I made:

1) Upon execution of the script, it checks for network connectivity. (Sees if the network path exists to the update file.)

2) Reads the Last Modified date of the file you are running and the file at the update location.

3) If the update file is newer then start an updater file.

4) The updater file kills the initial file and copies the newer file back over with confirmation of the new file date at the end in a splash window.

5) It then executes the newer file.

As so below:

(Code to put at top of your file you want to autoupdate)
$networkstatus = FileExists( "Updatedfilelocation" )

If $networkstatus = "1" THEN
$networkfile = FileGetTime ("Updatedfilelocation\filetoupdate", 0, 1)

$afiledate = FileGetTime ("Updatedfilelocation\filetoupdate", 0, 0)
$desktopfile =  FileGetTime(@DesktopDir & "\filetoupdate", 0, 1)

If $networkfile > $desktopfile THEN
SplashOff()
SplashTextOn("Filetoupdate", "A newer version has been found and is updating!  Please wait, the program will now restart...")
Sleep(2500)
SplashOff()
Run ("Pathtoupdater\updaterfile")
Exit
EndIf

(The Updater)
#include <GUIConstants.au3>
#include <Array.au3>
#include <File.au3>
$desktop = @desktopdir & "\filetoupdate"; Where the file presently is run from
$afiledate = FileGetTime ("Updated file location\filetoupdate", 0, 0); Gets the filetime for the updated file.
ProcessClose("filetoupdate"); Stop execution of the program to be updated
$tempdir = EnvGet ( "TEMP" )
FileCopy("Updated file location\filetoupdate", @DesktopDir, 1); Copies over the new file.
SplashTextOn("Updated", "The file has been updated to the latest version created on:" & @LF & $afiledate[1] & " " & $afiledate[2] & ", " & $afiledate[0] & " (" & $afiledate[3] & ":" & $afiledate[4] & ":" & $afiledate[5] & ")", -1, -1, -1, -1, 4, ""); Lets the user know that an update has occured.
Sleep(5000)
Run ("filetoupdate", @desktopdir); Executes the newly created/updated file.
Edited by Mr. Crimson
Posted

not to be an ass but:

This is not a general support forum

w0uter, is there a way to move a thread to the correct forum once it's started? Does this have to be done by the admin? In the future, if I want to reply to a mis-placed question, should I tell the poster to re-post in the correct forum first, then reply once/if that is done? Just looking for proper procedure... Thanks
...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format
Posted

Replying to a thread created in the wrong forum is perfectly acceptable. I believe Larry and Jon have the power to move threads to a better forum if they feel inclined to do so.

There's also no harm in a P.S. at the bottom of your response to the original poster to direct future queries to (the appropriate forum). Future is the key there because no one likes two threads on the same topic in two different forums.

Posted

The ap I am working on needs to be constantly updated, and while I do not do the actual update in autoit, there is no reason it could not be

First my ap is hundreds of files, of which hundreds of them could need to be updated at any time during an update.

(I use php, and most of my ap is php/html - though probably the second and third most important pieces of my ap is autoit (the most important being in c+))

The steps I go through are:

1) After I edit some files, I click a button to have a script run through all the files in my ap directory (with certain files/directories blocked), and create a hash of each file and place in a text file.

2) I compare the list of hashes from the last time I ran that script, to the list produced this time - any of them diffferent or new need to be sent up.

3) Another script grabs all the modified/new files - and if they are html/php it then compiles them, base64s them, encrypts the base64, and sends up to the web - which is received by a script there that throws it into a serialized array with the rest of the ap, binary and all is sitting in this))

4) I also send up a list of files that had been modified, each list of files is saved under a sequential number.

5) When a user updates, it grabs the list of files for each number after their last update, removes dups, and then grabs those files and send them down to the user where a script there uncompresses it, decrypts it, unbase64s it, and saves it over the old files and then updates the uses current version number.

I launch that from an autoit script that kills all running parts of the ap, launches the update window, and then kills the autoit tray menu that the update option is in (so as to not have them running if they need to be updated)

Granted thats probably a bit more than is needed for one file ;), but I figured I would share cause, well - the whole system freaking rocks :P

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...