Sign in to follow this  
md_lasalle

Self Updating .exe

Recommended Posts

md_lasalle    190
Hey, i'm working on a program that i just recently implanted... i'm doing a lot of updates evryday and i wanna make sure the end user has always my latest compile... my program as an .exe compiled with vb6 i dont have any problems on "how to make it check for update", more of the update process itself. i thought maybe i should make my prog write a .bat containing this : copy LatestVersion.exe OldVersion.exe -y //makes sure it overwrites run LatestVersion.exe but my question his, how can i start the .bat file and make sure the original prog isnt running so i can overwrite it? or is there a better way to self update an .exe? thanks

Share this post


Link to post
Share on other sites
MaulingMonkey    1728
Google Search: Self Updating .exe turned up some info, ironically, the exact same thing a was used as your title.

Try adding some more keywords (like the programming language you're using, which you failed to include in your post).

Another thing would be to investigate self deleting EXE files - it's close to the same process (modifying the .exe while the program is still running, or at least starting that process from the .exe)

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
well, the first thing that i can think of is :
The application downloads a newer version, saves it in a temp file, then launches another application and closes. The launched application then copies the temp file over the exe that needs to be updated, launches the updated exe and closes.

Share this post


Link to post
Share on other sites
Sphet    631
Why not have a system where, whenever a user starts your program, it actually runs a batch file:

@echo off
CheckForUpdate.EXE
TheMainProgram.EXE


CheckForUpdate.EXE checks if there is an update. If there is no update, CheckForUpdate.EXE quits immediately. If there was an updated, it downloads it and overwrites the original file. When it quits, the batch file continues and calls the new version of the program.

Wouldn't this work?

Share this post


Link to post
Share on other sites
Empirical    190
In my system the program checks for an avalible update, if so it downloads it as an EXE. It then launches the program with a special 'Install' run-command paramenter telling it it is in update mode. It then terminates saving its entire memory content(optional). The newly downloaded file waits for GENERIC_WRITE access to the EXE file it needs to write to then copys its self over. It then launches this file with the RECOVERY parameter (causing it to restore the memory) giving the impression of seamless updating.

You dont have to save the memory of course you tell the user to save there work normally.

Share this post


Link to post
Share on other sites
Evil Steve    2017
I've done this for my MUD client. Here's the process I use:
  1. Check for updates (Just reads a text file with the version number in it). If there's a new update, download the zip file, and extract it to the windows temp folder (with the users permission)
  2. Notify the user that the update is ready, then do a CreateProcess() (this is C++) and run the newly extracted version, passing it a command line parameter (/update), and the path to the old version (E.g. C:/DruinkIM/).
  3. Exit the old version of the app
  4. The app notices the /update parameter. Wait 100ms or so to give the old version time to exit. Then copy the contents of the current directory (the new version of the program) to the path specified in the command line
  5. Do another CreateProcess(), this time running the newly updated version (in E.g. C:/DruinkIM) and passing another command line parameter (/cleanup) and the path to the tempoary folder (where this process is running from)
  6. Exit the version of the app thats running from the temp folder
  7. The app notices the /cleanup parameter, waits 100ms for the other process to exit, then deletes all the files in the directory passed, so it cleans up the tempoary files.
  8. Continue running as usual


Cheers,
Steve

Share this post


Link to post
Share on other sites
Seriema    634
You could use Nullsoft Installer. They have two plugins that you could use. VPatch that allows patching ability, ie. the user doesn't have to download the whole file just the difference (VPatch comes with a app to make those "difference files"). And nsisdl that allows for downloading the files.

Share this post


Link to post
Share on other sites
md_lasalle    190
I like Sphet's idea, since its on a private network, it will be quite fast.

And by the way MaulingMonkey, i did say i was using vb6... nevermind anyway.

thanks evry1 for your help.

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