Click here to Skip to main content
Email Password   helpLost your password?

Introduction

This is a set of tools with which you can easily distribute automatic software updates to your clients.

Concept
picture #1

As you see in picture1 the ideal workflow to your clients is a direct line.
To get such an theoretical way working in an acceptbale way (in this solution), you will need to take the detour to the webserver. That means:

How does it work?

Concept
picture #2

As you see in picture2 the update-toolset consists of 3 different parts:

This program uses

Explanation of the basic functions

Producer-site:

(see picture3)
  1. Project is compiled
  2. packed
  3. uploaded to the webserver
  4. online-database is updated with the new version

Concept
picture #3

Customer-site:

(see picture4)
  1. UpdateClient is called to check for updates
  2. it request the actual version from the webserver
  3. it recaives the actual version number and compares it to its own hardcoded number
  4. when the online-version is newer, the update is fetched, otherwise the updatecheck is finished at this step.
  5. receive the update-file and saves it to a temporary folder
  6. unpacks to that temporary folder
  7. atm: only copies all content over the old one, without checking something

Concept
picture #4

Using the code

Set up the mysql table at the webserver:
#
# Table structure for table `version`
#

CREATE TABLE version (
  projectid int(11) NOT NULL default '0',
  projectname text NOT NULL,
  actualversion int(11) NOT NULL default '0',
  PRIMARY KEY  (projectid)
) TYPE=MyISAM;

Create a update.php script with following content:

<?php
mysql_connect("mydbserver.com","dbuser","dbpassword") or die(mysql_error());
mysql_select_db("mydb") or die(mysql_error());
switch($_GET["action"]){
 case "check": 
  $res=mysql_query(
"SELECT * FROM version WHERE projectname='".$_GET["project"]."'");
  $arr=mysql_fetch_array($res);
  echo $arr["actualversion"];
  die();
 break;
 case "setnew": 
  $res=mysql_query(
"UPDATE version SET actualversion=".$_GET["version"]." 
WHERE projectname='".$_GET["project"]."'");
  die();
 break;
 default:
  header("location:/");
  die();
  break;
} // switch

?>

Upload the update.php to the location specified in your updateclients. Don't forget to create the directory for the updates! integrate it into your application:

Public Class Form1
...
    Dim WithEvents updater As updateclient.clsClient
    Private Sub Form1_Load(ByVal sender As System.Object,
 ByVal e As System.EventArgs) Handles MyBase.Load
        updater = New updateclient.clsClient
        updater.CheckForNewVersion(ProjectName, VersionNumber, 
ProjectName, Application.ExecutablePath)
    End Sub
...
    Private Sub updater_endall() Handles updater.endall
        end
    End Sub
...
End Class
    
Module Module1
    Public Const ProjectName As String = "yourappname"
    Public Const VersionNumber As Integer = 25
    Public VersionDate As Date = New Date(2004, 10, 25) 'not used yet!

End Module

Points of Interest

Updates become more and more important in this fast-moving buisness. This toolset is just a fast-hacked starting point using the concept mentioned. You'll note that there exists no error handling, and many many more usefull features that are not included yet. Can your improve the concept or the toolset in any way?

History

You must Sign In to use this message board.
 
 
Per page   
 FirstPrevNext
GeneralNice idea... too complex.
Destiny777
10:05 14 Apr '08  
It would have been much easier to maintain by having say a "Text" file on a given directory on the FTP site for a program or a suite of programs.

/MyFTPSite/AutoUpdate/ProgramName.txt

Within the file show the latest software update data with containing a link to the download for the new software version and any other files that need to be updated / added with the update.

Say that the latest update for your software is April 15, 2008.

Have the file contain something like this:
2008-04-15
MyProgramName.EXE
File1.jpg
File2.jpg
...
etc.

Simple but elegant would be a great help!

Roll eyes
GeneralHello
ehrenberg
21:50 25 Feb '08  
This is verrryyyy niiicee, thanks. High Five!!
GeneralToooooooooo Complicated !!!!
abhi1310
1:31 16 Apr '07  
Hi, your program seems to be good, but very much complicated. I have seen a program recently and found to be good.
http://www.codeproject.com/vb/net/autoupdate.asp[^]
Hope this to be helpful to other users.

t

GeneralHow to get on the FTP? [modified]
unique_24
2:34 21 Jun '06  
Hi

For what is the FTPupdatepath ?

And how does I have to set for mySQL? Wenn I get in the UpdateCreator to upload the Files, in the mySQL I found no Entry!

Thanks

-- modified at 13:34 Wednesday 21st June, 2006
GeneralWindows Update.
Bikash Rai
2:33 14 Dec '05  
How does Windows Update work? It downloads a setup file silently in the background and installs it. The Update can also be seen in the add remove programs. How does it do it? Also what happens if the downloading is in progress and the user shuts down the system?

Any ideas? Cry

Bikash Rai
GeneralRe: Windows Update.
Nikola Knezevic
2:24 6 Mar '07  
One main thing:
Windows update is created by Microsoft as well as Windows OS. They know all the hidden stuff that's inside Windows so for them anything is possible.
Anyway you can also create silent istall but you nead to use some good installer software (e.g. InstallShield) or create your own.

--Nikola--

GeneralMaybe future version should have this ...
Vertyg0
9:02 7 Dec '05  
I will explain this on one example.
I have main application witch is Server and i have Clients on my local network, but only server has access to internet and only he can update files, now the problem/question is how to transfer files from Server to Client ?

GeneralLive Update App @ PSC
igorkrupitsky
11:16 27 May '05  
Thomas,

I really liked your application. However, I feel that the entire architecture can be reduced into a single app. By checking the Last Modified date of the zip file you can get rid of version checking mechanism.

Please check my “Live Update” application I have created inspired by your program. It also supports:

1) Encryption
2) Multiple folders in the zip file
3) Progress bar for downloading, unzipping and copying

http://www.planetsourcecode.com/vb/scripts/ShowCode.asp?txtCodeId=3640&lngWId=10
I hope that we can cooperate to create new application of this kind.


Regards,
Igor

GeneralRe: Live Update App @ PSC
thomasdev
4:08 29 May '05  
hi igor,

really great application and some basically better ideas, i sent u mail

thomas
GeneralMicrosoft's Updater Application Block
Anonymous
12:41 25 May '05  
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpag2/html/updaterv2.asp
GeneralNice, but how to update the UpdateClient
RSabet
12:40 29 Nov '04  
What if there is the need to update the UpdateClient ?

Possible improvement: the php-script should also return an URL where to get the update, if you want to change the server or path where to get the files.
GeneralRe: Nice, but how to update the UpdateClient
thomasdev
12:56 29 Nov '04  
>>>update the UpdateClient
this is one point where the concept leaks Smile

-- but my idea was to include the UpdateClient inside the update-package with a different name, for example updatenew.exe

so you must insert a routine in your main application that checks at startup whether that new updater exists. when it's existing then the app removes the old one and renames the new one to the name of the old one Big Grin

i hope this is a first practical solution that could be implemented without big changes.

the possible improvement of the php-script is a nice idea, when you've something working then it would be nice if you can send it to me, so that i can include it here

thanks for your contribution
GeneralNice but..
Pkef
1:02 8 Nov '04  
Oh well, nice article and a nice example for webupdate but, your php needs some lift up and better writing.. just note that when you die(); you stop the whole script.. there is no reason to break; after that..also note that header("location:/") won't work in case of an error before the switch.In addition it's better to do some validate to your action and assign it to a variable, than just parsing it over and over everytime you need it. Do sth like this:
$action = strip_tags ( trim ( $_GET['action'] ) );
strip_tags removes html tags , etc ( just in case someone finds out your webupdate script url and tries to mess it up) and trim removes the whitespaces from the left and the right of the string.. and something last, don't parse an array when you need to get just 1 result.. if there is just one result that is returned from your query it's better to do mysql_result($result,0,0);
Hope this helped..
That's all i had to say.. good work..
Cheers,
Cool

Pkef
GeneralRe: Nice but..
thomasdev
5:59 8 Nov '04  
thx for help!
i'll improve the article when there're more remarks


Last Updated 27 Oct 2004 | Advertise | Privacy | Terms of Use | Copyright © CodeProject, 1999-2010