application self update without restarting computer

  • Thread starter Thread starter Nick
  • Start date Start date
N

Nick

Hi,

I would like to make my application to automatically
check on updates from a source and if any, downloads it
and automatically updates itself with the new version.
Now because the application itself is running, I cannot
update the executable immediately, but need to request a
restart of the computer to automatically update itself.
Does anyone know how I can update the application without
having to restart the computer but is still transparent
to the user that the update is automatic?

Thanks!
 
Hi Nick,

Nick said:
Does anyone know how I can update the application without
having to restart the computer but is still transparent
to the user that the update is automatic?

There is a very interesting solution to do exactly what you want described
here:
http://windowsforms.net/articles/appupdater.aspx

Basically, the idea is that, instead of updating the application itself,
they make a copy of the running application, update this copy (this can be
done while the user uses the application as normal as the original remains
untouched) and the next time the user launch the application, the updated
copy is launched instead of the original. But all is very clearly desbribed
in this page.

They even have implemented this solution so you can download and use their
component "as it" or just use that idea to develop your own custom updater
component (which should be not very hard to do).
 
Take a look at the following:
http://msdn.microsoft.com/vbasic/us...px?pull=/library/en-us/dnbda/html/updater.asp
(watch wrap)

that is for the new application updater block from microsoft. there is
also another older version that was created by a different author on
gotdotnet.com called dotnetupdater. i use this version and it kind of
seems buggy sometimes if you don't do everything perfectly.

the updater application block is a little more tricky to get the hang
of but has ALOT more functionality/security when updating apps, plus
you can extend functionality of the application block to run your own
methods after update.
 
I would like to make my application to automatically
check on updates from a source and if any, downloads it
and automatically updates itself with the new version.
Now because the application itself is running, I cannot
update the executable immediately, but need to request a
restart of the computer to automatically update itself.
Does anyone know how I can update the application without
having to restart the computer but is still transparent
to the user that the update is automatic?

I did this several years ago for DOS, but here is the idea:
use a small application to start the big one

Let's say we have small.exe and big.exe

small.exe (pseudocode)

do {
if( exists( big.exe.new ) ) {
rename big.exe, big.exe.bak
rename big.exe.new, big.exe
}
exit_code = start_and_wait( big.exe );
} while( exit_code == restart ) {


big.exe ( pseudocode )

main() {
if( exists codedump )
load_all_data_structures( coredump );
else
init_all_data_structures();
run_the_thing();
}

periodic_check_for_new_version() { // using a timer or what you want
if( exists new_version ) {
download( new_version );
if( check_CRC( new_version ) == OK ) {
dump_all_data_structures( coredump );
fast_exit( restart );
}
else {
delete( new_version ); // bad CRC, risky!
}
}
}

=============================

I was able do dump/load the complete data structures.
Even more, in fast_exit I was not erasing the screen, then when
the application started with coredump, I just loaded all data
and went ahead. You did not see it change. The only thing: I had
a clock showing the seconds, and sometime you can see it skeeping
a second.
Other small trick: after downloading the new application and
checking the CRC I just set a flag. Then I wait to have no input
from the user for a while before coredump & fast_exit
(assuming that if the user did not care about my app. for 5 minutes,
I will not need it in the next 2 seconds, while I coredump and coreload).

This is the main idea. Sure, if load_all_data_structures fails
you have to call init_all_data_structures, if it succeeds you delete the
coredump). With Windows you can use other systems instead of exit code
(registry keys, the fact that the coredump exists, semaphores, etc)

May not be the best way, but the application is still running
(for the last 9 years)

Mihai
 
Back
Top