Page 1 of 1

update the executable of my application via FTP

PostPosted: Tue Jun 13, 2017 2:46 am
by MGA
Friends,

would someone have an example of how to create a routine to update the executable of my application via FTP?

Re: update the executable of my application via FTP

PostPosted: Tue Jun 13, 2017 7:31 am
by Marc Venken
I do this :

I have a global parameter table where I have a field : version. This field is the last released version.
I have a users database, where every user has his own field version :

I check the users version with the global version and when there is a difference, I copy the file from the server to his local machine :
Code: Select all  Expand view
  // versie update controle
   if oRs:versie <> system_version
     if URLDOWNLOADTOFILE( 0, "http:\\http://www.yoursite.com/fivewin/program.exe", "update.exe" ) = 0
        oRs:versie = system_version
        oRs:Save()
        msginfo("Update gevonden")
     endif
   endif

You need this DLL function :

DLL FUNCTION URLDOWNLOADTOFILE( pCaller AS LONG, cUrl AS LPSTR, cFileName AS LPSTR, nReserved AS DWORD, nFnCB AS LONG ) AS LONG;
    PASCAL FROM "URLDownloadToFileA" LIB "urlmon.dll"

 


It will copy the exe file as a Update.exe file to the local machine, since I was not able to copy the file as the original exe file, since the original file is allready loaded into the computer.

The users start the program with a batch file : start.bat with the folowing code.
If there is a update.exe the new version will be copy over the old version.

copy update.exe kabouters.exe
erase update.exe
start kabouters.exe
exit 0

I'm sure there are better ways, but this works. Maybe a better solution will come in this treat and can I addapt :wink:

Re: update the executable of my application via FTP

PostPosted: Tue Jun 13, 2017 2:42 pm
by Gale FORd
I am using TUpdate class and it works pretty good. I am using a modified version but the original works ok.
I think someone posted the code here:
http://forums.fivetechsupport.com/viewtopic.php?f=3&t=32310&p=189530&hilit=tupdate#p189530

Re: update the executable of my application via FTP

PostPosted: Wed Jun 14, 2017 11:32 am
by MGA
Marc Venken, Thanks!

Gale FORd thanks!
:D

Re: update the executable of my application via FTP

PostPosted: Fri Jun 16, 2017 4:49 pm
by Carlos Mora
SGS wrote:would someone have an example of how to create a routine to update the executable of my application via FTP?


There is a very good post of Byel about this topic that is worth to read.

http://bielsys.blogspot.com.es/2009/02/

It is in spanish, but you'll be able to read it with Google translator.

Regards

Re: update the executable of my application via FTP

PostPosted: Fri Jun 16, 2017 5:13 pm
by TimStone
Sorry to weigh in late on this. I not only had the need to auto install updates, but I also wanted to do backups everynight of all the data on the machine, and submit data for 3rd party vendors used by the clients.

I built an "AutoUpdate" executable on the primary machine. Every 3 hours it queries our server to see if there is an update. It also downloads a "keyfile" from our server which has a file ( encrypted ) of clients, and their version authorizations. I also have a rental program, so it contains the shut off date it payments are not received ( or the new extended authorization date when they are ). In the middle of the night ( after midnight ) when people are not likely on the system, it creates a backup archive file ( zip ) which it saves to a specified destination ( usually an external drive ), and it submits data to those vendors. Finally, it also sends emails to clients based on settings in the system ( especially thank you notes and reminders ).

When a new update is available, it does have the same name as the client executable, but it is downloaded to a sub folder on the primary (server) computer. When a person starts the client on their workstation, it actually calls a "run" program which checks for new copies of the .exe and .chm files on the server, and copies them to the local machine. Then it starts the client executable.

This system has been in place for many years, and it works beautifully. Sometimes when adding a new capability to the software, it can take a few "fine tuning" updates ... and of course if there is an error, it can be fixed and made available immediately.

The auto updater runs 24/7 and right clicking on the icon will bring up a menu where the log can be displayed, and also a person can do an immediate update request. So, in our "real world" if someone finds a bug that interferes with their operations, calls it in at 8:00 am, by 8:10 it is fixed, a new .exe is built and pushed to the server, and they can manually request an update. Thus, they can be running bug free by 8:15. Since most bugs are typos, fixes are usually very fast, and this operation is very easy.

The actual code is rather simple ... just write it to generally avoid any screen displays so it is fast and efficient.

I've tried to build this as a windows service, and so far have not been successful. I believe it will happen in the near future, however, once I determine which library elements ( unused but present ) are blocking that ability.

Tim

Re: update the executable of my application via FTP

PostPosted: Fri Jun 16, 2017 8:13 pm
by Marc Venken
it actually calls a "run" program which checks for new copies of the .exe and .chm files on the server, and copies them to the local machine. Then it starts the client executable.


Is this a exe file running, looking for the update, copy if needed and than calling you exe file ?

I use a bat file like above, but it has that annoying black old screen.

Re: update the executable of my application via FTP

PostPosted: Fri Jun 16, 2017 9:10 pm
by TimStone
Yes, it is an .exe that I created. It has more intelligence than a bat file ....

Re: update the executable of my application via FTP

PostPosted: Fri Jun 16, 2017 9:41 pm
by Marc Venken
So, Your Run program on every client will call afther the update/copy the new version to launch. I suppose with a waitrun or so ?
But the Run program will also be running 24/7 or when do you close this?

What happens if the client closes your 24/7 update program. Your backup system will fail not ?

Re: update the executable of my application via FTP

PostPosted: Fri Jun 16, 2017 10:59 pm
by TimStone
Marc,

The program on the server runs 24/7. If they turn it off, it obviously cannot work. However, when they turn it back on, it "catches up".

The desktop icon on the workstation points to the local update program. When someone exits the program, then restarts it, that is when it checks the server to see if there is a more recent copy of the main executable. If so, it copies it over. It also does the same with other files it checks for updated versions. Then it starts the program. This usually just takes a few seconds. Our clients do not keep the programs running when they leave at the end of the workday.

The bottom line is it works VERY WELL.

Tim

Re: update the executable of my application via FTP

PostPosted: Mon Jun 19, 2017 12:33 pm
by MGA
Carlos Mora,

Worked perfectly, thank you!

Re: update the executable of my application via FTP

PostPosted: Mon Jun 19, 2017 1:01 pm
by Marc Venken
SGS wrote:Carlos Mora,

Worked perfectly, thank you!


I did not look yet. Is in spanisch :!: Will use Google to translate, but did it worked like it is posted, or did you have to make extra changes ?

Re: update the executable of my application via FTP

PostPosted: Mon Jun 19, 2017 6:54 pm
by MGA
Marc Venken,

http://bielsys.blogspot.com.es/2009/02/

Worked perfectly, I made some adjustments just to fit my specific needs. The original source code works perfectly.