Updating System

Hello experts!

I have a Product based on a few Delphi applications (.EXE). This Product runs on several PCs in several cities in my country. We started out with a few locations, so I could update the applications with little effort. But now the project is growing fast, so I need to build an update system for the applications (like anti-virus application).

What’s the best way to do that?

This is what I have in mind so far:

All PCs are already connected to a main MySQL server. And one of the applications already works with FTP.  I could store the latest version of each application on MySQL, and I could build a program that would check the version of each application, download the new .EXEs when necessary, and install them. To install them, I would just have to stop the running application and copy the new EXE over the old one. I just don’t know how can I close a running application! How to I do that?

Or is there a better way to do that?

Oh, and this has to be completely standalone, the PCs don’t have any human operator. The process must be automatic.

Thanks a lot.
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.

A "simple" way would be to execute a batch file. Because if a process is running, the executable image cannot be deleted. Therefore, if you download (via FTP) the update and call it, say myprog.bak and the original programme is myprog.exe, you can have a batch file as follows:

@echo off
del myprog.exe
if exist myprog.exe goto DoDelete
ren myprog.bak myprog.exe

You would then execute the batch file and terminate self (either by closing the main form or Application.Terminate).

TheRealLokiSenior DeveloperCommented:
if the running application has a form, you can do a FindWindow, and send a WM_Close message to it

ahandle := FindWindow('Notepad', 'Untitiled - Notepad'); // class name, window name e.g. FindWindow('TForm1', 'Form1')

if aHandle <> 0 then
  sendmessage(aHandle,wm_CancelMode,0,0); // to close a dialog first, then call the wm_close

If it is a service, you can just do
Net Stop [servicename]

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
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

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.