Updating the Application's EXE file

I would like my Application to check, every time it runs, if there's a newer version of it on the company's intranet, and if there is a newer version, it should replace itself with the new version. (Download the new EXE app version, and replace the old EXE file).
If there's a new version, it should terminate itself and run the new version.
Next time the APP runs, the new EXE file should run.

I can deal with checking for a new version, and downloading it via HTTP.
But, how do I replace the EXE file which is now running with a newer version? Is it a safe thing to do ? How can I do it in another way, if not? (I want the EXE replaced, not to just D/L and run it each time).
xozAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mflamCommented:
There should be no problem:
1. Mark your "old version" as "dirty"
2. Hide your old form (window) from user interface.
3. Put up message: downloading new version.
4. Download new version.
5. Run new version (from old one).
6. Have new version tell old one it's up. (via pipe or win32 message or winsock or shared file or whatever), and shut down.
Or... Just shut down after some timeout...

Calling the Exec Program on the disk should have nothing to do with your process (running program) in memory.

The problem will be with file sharing.
You may not be able to overwrite or delete the file that's running.
The easiest way is to simply use 2 alternate names. If you are Proj1 download and run Proj2. If it's proj2 download and run proj1.

Another completely different approach:
Make a small extra program: CheckVersion.
It will run from your oldProj. If it finds newer version it closes oldProj (either sends message telling it to shut itself, or sends it a Win32 terminating message) and downloads and runs newer version.
Symantec have a program like this in their Visual Java program. It constantly (once every so and so) monitors the net, and checks for a newer version.

Hope this helps, Moshe
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
xozAuthor Commented:
How do I send a message telling the App to shut itself ?
How do I send a win32 terminating message?
0
KDivadCommented:
Maybe easier:
Have the app (once it notices the newer version) shell out a small app designed just for this transfer and end itself. The small app should now download the new exe. Once the it is downloaded, shell it and have the small app end itself.

Later,
0
xozAuthor Commented:
Thanks.

Now just for general knowledge:
How do I send a message telling the App to shut itself ?
How do I send a win32 terminating message?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming Languages-Other

From novice to tech pro — start learning today.