Updating your program?

Just starting out? Need help? Post your questions and find answers here.
vwidmer
Enthusiast
Enthusiast
Posts: 282
Joined: Mon Jan 20, 2014 6:32 pm

Updating your program?

Post by vwidmer »

How do you update your software?

Do you have them download new version and install over?

Do you have it done from with in the software? If so does any one have an examples?

Thanks
WARNING: I dont know what I am doing! I just put stuff here and there and sometimes like magic it works. So please improve on my code and post your changes so I can learn more. TIA
User avatar
skywalk
Addict
Addict
Posts: 4003
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: Updating your program?

Post by skywalk »

My Windows apps look to a release notes text file on a server, (MyApp.txt or MyApp.md).
It could also be a database file and a query, but this is more simple as it is also the checkin comment for my source control program, Fossil. The file is a trackable document.
Each paragraph starts with a date based version followed by notes:
19.07.06
1) Fixed typo blah blah.
2) Added amazing feature blah blah.
19.06.26
1) Internal fixes and recompiled external lib blah blah.

On 'Check Version' menu request, the MyApp compares the topmost version with its current and prompts the user with a request to upgrade? The user can see 'what's new' and decide.
If user agrees, MyApp does the following:
; Steps:
; 1. Check remote location for available version?
; 2. If newer, copy remote file to local path as new-app.exe
; 3. Create and save batch file to local path as app-upg.bat
; 4. Run app-upg.bat. It has a 6sec delay inside to allow this app.exe to quit.
; 5. Quit app.exe
; 6. app-upg.bat will delete any local app-xxyyzz.exe
; 7. app-upg.bat will rename local app.exe to old-app.exe
; 8. app-upg.bat will rename local new-app.exe to app.exe
; 9. app-upg.bat will start app.exe.
;10. New app.exe does cleanup on startup.
; Clean up windows/files left after an upgrade.
; DeleteFile(ai\Path$ + "MyApp-upg.cmd")
; DeleteFile(ai\Path$ + "new-MyApp.exe") ; Should already be deleted.
; Close cmd.exe window.

Depending on network access, VPN, Local LAN, this happens in a blink.
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
vwidmer
Enthusiast
Enthusiast
Posts: 282
Joined: Mon Jan 20, 2014 6:32 pm

Re: Updating your program?

Post by vwidmer »

Ok well I am trying to do something a little more cross-platform so

going off what you said this is how I am thinking...

1. Check for update. In the check it will get version and checksum of new update.
2. if newer.. download a compressed file
3. check its checksum to make sure its not corrupt.
4. if checksum = good then un compress
5. ****** here is the part I think need a little help on *****
--- In the compressed file I will have a UPDATER app which will do the actual update.
--- A ) have the running app launch the UPDATER app then exit and run UPDATER assuming current app quit correctly.
--- B ) have the running app launch the UPDATER app and some how send a signal to the current app to see if running and if so send an exit to it and then when ready run the update.
6. UPDATER will move current app to a .bak file
7. move new version
8. launch new version and try to communicate with it that it was successfully started
9. if so the do cleanup

So I guess if some one has an idea or best way on how I can communicate between the two that would be great.

Thanks
WARNING: I dont know what I am doing! I just put stuff here and there and sometimes like magic it works. So please improve on my code and post your changes so I can learn more. TIA
User avatar
skywalk
Addict
Addict
Posts: 4003
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: Updating your program?

Post by skywalk »

My approach is still cross platform. Batch,sh scripts, etc. exist in all OS's.
The reason for my approach was antivirus mechanisms prevent recently downloaded files to immediately execute. But, if your current app is whitelisted, it can create a bat file and run it and immediately close. Then the batch file does the download and renaming and call to the new version of the same MyApp.exe.
This fails if the antivirus demands your whitelisted MyApp.exe have a specific hash. That prevents any upgrades without Admin rights.
The batch file can perform the unzipping and hash comparison if you need.
What communication are you requiring?
MyApp.exe is closed.
MyApp.bat is running.
MyApp.exe 2.0 is now running.
MyApp.exe 2.0 always runs a cleanup routine if it detects MyApp.bat.
MyApp is now upgraded.
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
User avatar
DeanH
Enthusiast
Enthusiast
Posts: 229
Joined: Wed May 07, 2008 4:57 am
Location: Adelaide, South Australia
Contact:

Re: Updating your program?

Post by DeanH »

Sounds like a similar procedure to the one I employ.

My Bookmark library system is updated every month as users are constantly requesting tweaks, new functions, reports, etc.

1. As part of the "start of day" routine, the program auto-downloads a little text file which contains the current version / build number. If it is different from the running program, the user sees a popup window notifying of the update.
2. Options are to update now or later.
3. If the user clicks on Update Now, then a 25k zipped file (actually lzh format) is downloaded. This contains the exe (Updater) that does the actual updating.
4. The Updater is run. It presents a dialog with 3 "sources" (different folders on the webserver) and start and abort buttons.
5. On Start Update, a zip (lzh) file containing the update downloads, showing a progressbar.
6. After a successful download, the Updater saves a small text file called "Update.tmp".
7. The main program - still running - checks for this file during event loops. If present, the program shuts itself down. I do it this way as program modules (there are a dozen) can be open on various workstations.
8. The still-running "downloader" then unzips the update (LHA32 is used as it shows a nice progressbar while extracting or packing) and gives a report on how many modules were updated.
9. The user then manually restarts the program.
10. The updater program itself and the tmp file are automatically deleted.

All of this is written in PureBasic.

I also send an email out to all users notifying of the update.

Problems: dodgy internet connections, Internet cache retaining an older copy of the update file, URL is locally blocked by a group policy or security, and the biggest problem is proxy settings on workstations which can cause download failures.

I have debated whether or not the program should update each module separately, and whether documentation (embedded in the update zip) should only be online and not supplied with each update. Still have a significant number of users - mostly schools - that have poor or even no Internet, and have to resort to a different procedure to update. However, things are rapidly improving as fibre optic cable and upgraded hardware is finally being rolled out to schools.
vwidmer
Enthusiast
Enthusiast
Posts: 282
Joined: Mon Jan 20, 2014 6:32 pm

Re: Updating your program?

Post by vwidmer »

So after @skywalk post I have now changed it a little and playing with embedding the updater in the main application. Do you think this will have the same effect as creating a script vs downloading a file in terms of antivirus?
WARNING: I dont know what I am doing! I just put stuff here and there and sometimes like magic it works. So please improve on my code and post your changes so I can learn more. TIA
User avatar
oreopa
Enthusiast
Enthusiast
Posts: 281
Joined: Sat Jun 24, 2006 3:29 am
Location: Edinburgh, Scotland.

Re: Updating your program?

Post by oreopa »

I think perhaps the simple way is good:

seperate update app that is called with current version number as argument from main app
update app checks ver.txt on server
if newer exists then close main app as normal from update app, dl/apply, restart main app
else display "UP TO DATE" and quit update app.

You could use #wm_COPYDATA (cross platform shoudl exist) to pass data and also set a mutex in main program to see if is running from updater.
Proud supporter of PB! * Musician * C64/6502 Freak
Post Reply