self update exe?
-
hiho@ll anyone knows how to write a exe which is currently running? what i need: solution 1: 1. execute test.exe 2. download updated test.exe 3. overwrite test.exe with the updated test.exe solution 2: i know i could download in a temporary directory create a bat file close my application and execute bat file, which copys the exe, executes the new exe and deletes itself (test.bat) but, how i can execute the bat file and make sure the test.exe application is closed so i can overwrite it with the downloaded? OR is there a way to do it like solution 1? thx@ll
-
hiho@ll anyone knows how to write a exe which is currently running? what i need: solution 1: 1. execute test.exe 2. download updated test.exe 3. overwrite test.exe with the updated test.exe solution 2: i know i could download in a temporary directory create a bat file close my application and execute bat file, which copys the exe, executes the new exe and deletes itself (test.bat) but, how i can execute the bat file and make sure the test.exe application is closed so i can overwrite it with the downloaded? OR is there a way to do it like solution 1? thx@ll
A slight twist to solution 1: 1. execute test.exe 2. test.exe executes checkupd.exe 3. checkupd.exe checks for updates. 4. if any are found: 4a. terminate test.exe 4b. download test.exe 4c. execute new test.exe 5. checkupd.exe is ended Otherwise if you must do everything from within test.exe, check out the
MoveFileEx(..., MOVEFILE_DELAY_UNTIL_REBOOT)
function.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
-
A slight twist to solution 1: 1. execute test.exe 2. test.exe executes checkupd.exe 3. checkupd.exe checks for updates. 4. if any are found: 4a. terminate test.exe 4b. download test.exe 4c. execute new test.exe 5. checkupd.exe is ended Otherwise if you must do everything from within test.exe, check out the
MoveFileEx(..., MOVEFILE_DELAY_UNTIL_REBOOT)
function.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
I do something similar to this for getting my programs to update themselves from the web. But I use an MSI for distribution so that is the second program in the scenario. I like your solution because you can easily execute the updated program when it has finished. My method was: 1. Check for updates 2. If any found, confirm and download into user Temp directory 3. ShellExecute the MSI package (/qb) just downloaded 4. PostQuitMessage on self The installer updates the program and then leaves the user back at the desktop. I never thought of a good way to restart the application. I might try something like yours next time.