LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Self-updating exe (copy over exe while running)

This may not be possible, but I'm running a program, say App.exe.  I've written a simple updater where App.exe goes to a URL and from there, finds updated versions of itself (if any).  The user selects one, and the App.exe is then able to download the latest App.exe.  I'd like to make this painless for the user and run it like how other programs (like Firefox) do it: to simply pop up a box that says 'Restart App.exe', and it then restarts with the updated code.

The problem I'm having is although I can get the raw data from the new App.exe (using DataSocket, and the trick where you add "[text]" to the URL), but I can't save it as App.exe due to a file permission error (makes sense, as App.exe is currently locked since it's running).  I can save it as something esle (like App2.exe) though.

And once I'm able to copy the file correctly (if that's possible), does anyone know how to restart a program?  I might just have to come up withi a program that copies App2.exe to App.exe, but I'll have to run that from App.exe, then have App.exe close.

If anyone has any ideas, just let me know.  The other option is to just write a batch file that copies one program to the other, and give the user very explicit instructions.  But if it's possible to avoid that, that would be a nice feature.

Thanks!
-- Rick
0 Kudos
Message 1 of 2
(4,223 Views)
App.exe could start the copying batch file and exit. Once App.exe is finished the batch file can copy and start new version without user intervention.

I suggest you make a small AppUpdater.exe application that takes care of stopping App.exe and copying App2.exe and starting it.


LabVIEW, C'est LabVIEW

0 Kudos
Message 2 of 2
(4,212 Views)