Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Updating EXE file from server…

Tags:

delphi

I need to update my application from a central server.

The application checks always if it is a correct version, against the server installation.

So when it is not, I need it to update itself.

So how can I copy the EXE if it is running? What solution do I have?

like image 328
Jlouro Avatar asked May 12 '11 13:05

Jlouro


People also ask

Can you change exe files?

EXE file is a compiled file. If you want to change the file type, it must be converted or saved as the destination file type, with the appropriate file extension.

What is update exe file?

UPDATE. EXE is a legitimate executable file developed by Microsoft Corporation. This process is known as Windows Service Pack Setup and it belongs to the software Windows Operating System. It is commonly stored in C:\Program Files. Cybercriminals find a way out to mimic malicious programs in the name of UPDATE.

Where is Windows Update exe file located?

The Wusa.exe file is in the %windir%\System32 folder. The Windows Update Standalone Installer uses the Windows Update Agent API to install update packages.


4 Answers

I rename the current running exe to MyTempExe.exe, copy the new exe to the correct location (request elevated privileges if necessary) and then run a separate app to restart the main app. On start up I check for MyTempExe.exe delete it if it's there.

The reason I use a separate app for the restart is I don't have a set time frame for the app to close down and need to wait for it to finish whatever it's doing, on shutdown it writes information to disk about its current state that the updated app will use to resume where the old one left off.

I don't know if it's the best solution but it's the one I use.

like image 144
James Barrass Avatar answered Oct 13 '22 21:10

James Barrass


As you can see by all the answers there is no set way to do this, so I thought I would add the way we have successfully done this.

  1. We never run an application directly from the network.
  2. We run the application from the local machine and have it copy from the network on startup.

We do this using an application launcher. It downloads an XML file that contains CRC and Version Resource Values for the application files. The XML File is created during the deployment process, in a FinalBuilder Script.

The application then compares the XML File to local content, and copies down needed files. Finally we then launch the application in question. This has worked well for deploying an application that serves around 300 local users. Recently we switch from a file copy to an HTTP download as we found problems with remote user disconnecting drives.

We still still build installations (With Innosetup) to get the basic required files deployed.

like image 3
Robert Love Avatar answered Oct 13 '22 22:10

Robert Love


Package your app with an installer such as Inno. Download and execute the installer. Have the installer search for and kill your app, or instruct the user to close it. The setup will replace your .exe, and if the app can't be killed or the user is non-cooperative, it'll issue a re-start notice.

like image 3
Chris Thornton Avatar answered Oct 13 '22 21:10

Chris Thornton


  • Download new EXE to TEMP
  • Create Batch from EXE, content:

taskkill /PID %process id of running EXE%

copy %new EXE% %running EXE%

%EXE%

  • all values in %...% are placeholders
  • execute batch from the running EXE
  • delete batch
like image 3
Matthias Alleweldt Avatar answered Oct 13 '22 22:10

Matthias Alleweldt