Go Premium for a chance to win a PS4. Enter to Win


how to update exe applicatio from internet ?

Posted on 2016-11-16
Medium Priority
Last Modified: 2016-11-16
i am using this procedure to update my application from internet  , But i got problem i already can download the new exe ,, but i wanted to auto replace the old application with the new updated one  i cannot do that while the exe application is running !

the approach that i am trying to achieve is when i run my application and download the update auto restart the application with the new update one  , i don't want to duplicated Files like rename and leave the old version etc  

procedure TForm1.DownLoadNewVersion1Click(Sender: TObject);
  apath: string;
  new: Integer;
  // This is the exact code from my application
  apath           := GetPathPath;
  Gauge1.Progress := 0;
  StatusBar1.SimplePanel := True;
  StatusBar1.SimpleText := 'Connecting to http://tsoft.home.ro';
  Gauge1.Progress := 20;
  if DownloadFile('http://www.tsoft.home.ro/update.ini', PChar(apath) + '/update.ini') then
    Gauge1.Progress := 50;
    StatusBAr1.SimplePanel := True;
    StatusBar1.SimpleText := 'Checking for newer versions...';
    vernfo := TiniFile.Create(GetPathPath + '/update.ini');
    new    := vernfo.ReadInteger('version', 'wsc', 7);
    if (old = new) then
      StatusBar1.SimplePanel := True;
      StatusBar1.SimpleText  := 'No new version detected';
      Gauge1.Progress        := 100;
    else if DownloadFile('http://www.tsoft.home.ro/winsafe.exe',
      PChar(apath) + '/winsafe.exe') then
      ShowMessage('Update succeseful');
      Gauge1.Progress := 100;
      winsc           := TIniFile.Create(ChangeFileExt(Application.ExeName, '.ini'));
      winsc.WriteInteger('wsc', 'vernfo', new);
      MessageDlg('A new version has appeard but it requires a second install',
        mtInformation, [mbOK], 0);
    StatusBar1.SimplePanel := True;
    StatusBar1.SimpleText  := 'Failed to connect probably a internet problem';
    Gauge1.Progress        := 0;

Open in new window

Question by:dolphin King
  • 3
  • 2
LVL 37

Expert Comment

ID: 41889562
That's why all major software releases (think Google Chrome, Adobe Reader etc) use a separate update modules. It's just not possible to update yourself.

Author Comment

by:dolphin King
ID: 41889675
so you suggest to create a luncher to the orginal exe that need to be updated ?
LVL 37

Accepted Solution

Kimputer earned 2000 total points
ID: 41889682
I suggest you start the update module (separate .exe) to update the main program (have it close the main app if it's still open).
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.


Author Comment

by:dolphin King
ID: 41889847
i will take your suggestion as accepted answer how ever i was thinking about something else ...
LVL 38

Expert Comment

by:Geert Gruwez
ID: 41890289
Letting an exe update itself doesnt work.
There is always a second app required which can need elevated privs.

You can lift someone except yourself

Author Comment

by:dolphin King
ID: 41890502
yes i was thinking flat . i did secondary app

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

876 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