Archive: Self Update


Self Update
I have created a launcher application using NSIS, which first checks for updates of the program on a network share and launches the program if no updates are found. If they are found then it updates the local system before proceding. Every so often I have an update for the launcher itself but it cannot update itself while it is still running. Therefore I use this code to update it. But it only works after the computer is restarted.

  MessageBox MB_OK "$\"Launch.exe$\" Update Found: $LocalVer to $ServerVer"
GetTempFileName "$0" "$Local"
CopyFiles /Silent "$Server\Launch.exe" "$0"
Rename /RebootOK "$0" "$Local\Launch.exe"
Is there a way to update the launcher program and get it to automatically startup after the update is finnished and continue with the execution without the need to restart the computer.

Vytautas

Can't you do something similar to what the uninstaller is doing.

When first started, check the directory you're running in. If it isn't the temp folder, copy yourself to the tempfolder (under a temporary name) and execute that copy and exit the first instance (all this before a GUI is shown)

Alternatively, you could check to see if a certain commandline parameter is added or left to decide to copy yourself to the temp folder.

Now, you can check if the launcher is up to date, and if it needs to be updated, you can just copy it over the old one in the original directory. You then exit and call the new launcher, which will do the above process all over again.

Remco


Check the NSIS Update source, it uses the same trick.


Thanks for your hints. I have figgured out a nice way of doing this in my launcher program. Just in case it can help anyone else out there I will attach the launcher program script.

Vytautas