Solved

how to update exe applicatio from internet ?

Posted on 2016-11-16
6
91 Views
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);
var
  apath: string;
  new: Integer;
begin
  // 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
  begin
    Gauge1.Progress := 50;
    StatusBAr1.SimplePanel := True;
    StatusBar1.SimpleText := 'Checking for newer versions...';
    vernfo := TiniFile.Create(GetPathPath + '/update.ini');
    new    := vernfo.ReadInteger('version', 'wsc', 7);
    vernfo.Free;
    if (old = new) then
    begin
      StatusBar1.SimplePanel := True;
      StatusBar1.SimpleText  := 'No new version detected';
      Gauge1.Progress        := 100;
    end
    else if DownloadFile('http://www.tsoft.home.ro/winsafe.exe',
      PChar(apath) + '/winsafe.exe') then
    begin
      ShowMessage('Update succeseful');
      Gauge1.Progress := 100;
      winsc           := TIniFile.Create(ChangeFileExt(Application.ExeName, '.ini'));
      winsc.WriteInteger('wsc', 'vernfo', new);
      winsc.Free;
    end
    else 
      MessageDlg('A new version has appeard but it requires a second install',
        mtInformation, [mbOK], 0);
  end
  else
  begin
    StatusBar1.SimplePanel := True;
    StatusBar1.SimpleText  := 'Failed to connect probably a internet problem';
    Gauge1.Progress        := 0;
  end;
end;

Open in new window

0
Comment
Question by:dolphin King
  • 3
  • 2
6 Comments
 
LVL 35

Expert Comment

by:Kimputer
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.
0
 

Author Comment

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

Accepted Solution

by:
Kimputer earned 500 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).
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

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

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
0
 

Author Comment

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

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ejb stateless example 2 40
printf performancy 11 83
Delphi android app hide keyboard 3 40
Problem working with dynamic array - help 2 35
A short article about problems I had with the new location API and permissions in Marshmallow
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

713 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