Archived

This topic is now archived and is closed to further replies.

Zern

How to replace a currently running exe..

Recommended Posts

Zern    138
Hello, I''ll get straight to the point, I created a patcher program that can update itself. I download the new executable to a file called "programname.ex_". My question is how do I in turn, have the currently running patcher, delete itself while renaming the "programname.ex_" to -> "programname.exe." My thoughts are to create an additional simple application that will replace all file extentions ( *.ex_ ) ( *.ba_ ) etc whatever I add to it, to *.exe *.bah. Start this simple application through a CreateProcess function. That is the only way I see fit, however is there a way to have an executable replace itself without firing up another application to do the deleting/renaming? Thanks in advanced. ~

Share this post


Link to post
Share on other sites
Zern    138
quote:
Original post by niyaw
MoveFileEx(..., ..., MOVEFILE_DELAY_UNTIL_REBOOT);


[edited by - niyaw on January 30, 2003 4:24:45 PM]



I seen that but noticed it only works on Win NT3.1 + and not Win95/98/ME. Also waiting until the system reboots to replace the file seems a bit annoying to have the user reboot just to have an updated client. However thanks for your time.



Extrarius, nice link. Thank you as well.


I believe creating a batch file is the best way to go about this. CreateProcess hiding the window using techniques provided by the link Extrarius gave to give the new batchprocess very low cpu priority, then have it replace the old files with the new .


Thanks again to both of you.

~

Share this post


Link to post
Share on other sites
Aface    124
Hi there silly bear,
I did this using VB, but the same methods apply. What i did was check for a new *.exe version - if there was one, then rename the current exe old*.exe (you can rename an exe whilst running). Then, copy the new exe to the old exe''s folder and name it *.exe. Then send a message box to the user letting them know to restart the program (their shortcuts now point to the new version). Lastly, or firstly as the case may be, every time the program starts, it checks its folder for old*.exe and deletes it if found.

The only drawback to this method is that the user must restart the program.

Hope this fucking helps

aface

Share this post


Link to post
Share on other sites
Ready4Dis    180
LOL, you could simply spawn the new application when finished, and unload yourself.. that way they don''t even have to manually do it . Good advice though, simply rename to an old.exe or whatever, and rename the game.ex_ file to game.exe, then spawn the new process (game.exe), then close itself. The game.exe file would check for old files, and delete them. Should work fine that way.

Share this post


Link to post
Share on other sites
Zern    138
quote:
Original post by Aface
Hi there silly bear,
I did this using VB, but the same methods apply. What i did was check for a new *.exe version - if there was one, then rename the current exe old*.exe (you can rename an exe whilst running). Then, copy the new exe to the old exe''s folder and name it *.exe. Then send a message box to the user letting them know to restart the program (their shortcuts now point to the new version). Lastly, or firstly as the case may be, every time the program starts, it checks its folder for old*.exe and deletes it if found.

The only drawback to this method is that the user must restart the program.

Hope this fucking helps

aface




LOL another idea that sounds good.

Ready4Dis - Yes, I am going to have it automated ( download the updated client/extra files - delete/rename to correct names, reload the new exe if found else no need to close the original until done updating ).


Thanks for the responces

Share this post


Link to post
Share on other sites