Updating System

Posted on 2006-04-17
Last Modified: 2010-04-05
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.
Question by:rogerbrito
    LVL 14

    Expert Comment

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

    LVL 17

    Accepted Solution

    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]

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
    Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    730 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now