Update and restart

just write whatever you want
Post Reply
fsurfer
Posts: 23
Joined: Thu Jul 08, 2004 9:53 am

Update and restart

Post by fsurfer »

Hi everyone,

i wanted to post you personally, madshi, but it think it may be helpful for other people.

Actually, i'm searching a way to update my application by an automatic update. As in many app i've seen, my wish is to connect to a server (through HTTP connection), download the update program file, close the app, run the update, and then re-run the main app. I want to do such an update because i'm a cybercafe manager and i have more than 30 computers to manage :).

I've already done it, but my problem is the following :
here's the algorithm i use to do the update :
MAIN_APP :
- download app
- execute downloaded app
- close itself (and uninject hooking DLLs :)

UPDATE_APP :
- wait for the system to completely unload the MAIN_APP
- check that none of the updated files are loaded
- uncompress and overwrite the files
- execute the MAIN_APP
- close itself

My problem occurs during the second and third lines of the UPDATE_APP algorithm. Sometimes hooking DLLs are still in memory, so overwrite is impossible (that was one of my reason, madshi, of my post concerning uninjection DLL doesn't always seem to work). Sometimes, although all the files are unloaded from memory, the 'uncompress and overwrite' process doesn't work, saying nothing. In fact, it goes through the uncompress and overwrite but the file isn't overwritten. it's still the old version. and the TFileStream.Create doesn't raise any exception (file acces violation, etc...)

In fact, my post is more a question about the way to do such an update.
Does anyone of you has a better idea or a solution for my problem ?

Or may be a component exists to do such things ?

Another idea i have, is to have an application running as a process that pilots the update (closing, running the update app, re running the main app).

thanks for your help !

Best regards,

Guillaume
madshi
Site Admin
Posts: 10754
Joined: Sun Mar 21, 2004 5:25 pm

Post by madshi »

You should be using MoveFileEx with the MOVE_FILE_AFTER_REBOOT flag for winNT and you should use the wininit.ini in win9x. This way you can store files so that Windows will rename them during the next reboot. That's how every installer replaces files which are in use.
Post Reply