Board index » cppbuilder » Upgrading an application from within

Upgrading an application from within


2005-07-15 11:01:48 PM
cppbuilder57
Hi,
I want to be able to replace an application's .exe file from within the
application in response to a user action. As this cannot be done whilst the
application is still running, how can I make it start a batch file (or even
another exe) after terminating?
Paul
 
 

Re:Upgrading an application from within

Paul Dowd wrote:
Quote
Hi,

I want to be able to replace an application's .exe file from within
the application in response to a user action. As this cannot be done
whilst the application is still running, how can I make it start a
batch file (or even another exe) after terminating?

Paul
AS your Application.exe exits, start up the Upgrader.exe but don't wait
for Upgrader.exe to exit. Look up CreateProcess() in the win32 API for
information on how to do this. When Upgrader.exe starts, wait until
Application.exe terminates. You can define various ways of achieving
this, but the simplest is probably for Upgrader.exe to continually
attempt to overwrite Application.exe until it succeeds.
 

Re:Upgrading an application from within

"Rob" < XXXX@XXXXX.COM >wrote in message
Quote
When Upgrader.exe starts, wait until Application.exe terminates.
You can define various ways of achieving this, but the simplest is
probably for Upgrader.exe to continually attempt to overwrite
Application.exe until it succeeds.
A more efficient way is for Application.exe to pass its process ID as a
command-line parameter to Upgrader.exe, and then Upgrader.exe can call
OpenProcess() and WaitForSingleObject() to wait for Application.exe to
terminate, and then overwrite the file as needed.
Gambit
 

{smallsort}