TWebUpdate - simple version check / update on load

I am interested in implementing a simple automatic update scheme for a few of our applications. Before I invest too much time, I was wondering if anyone could tell me if this component is the right approach.

What I want to do is simply check a local folder for an updated copy of the application that is running (based on the version number) and swap it in on load if there is one present. I would prefer to not have to make some sort of upgrade package or patch.

TWebUpdate can do this. It can use local files to compare version info with and when a newer version is found, the application EXE will be closed, will be replaced with the new EXE the .INF file is pointing at and will restart the new version.

Exactly the answer I was hoping for. Is the INF an external file that just defines what update action to perform, or is that specific to a version? i.e. Can I just throw a new EXE into a designated folder and trust that my application will just update itself on load using TWebUpdate magic? Or do I need to generate and INF file for each new release?

Thanks for your reply, and for making such great components!

The .INF file describes the update process.
It is described in the TWebUpdate developers guide

There is also a tool UpdateBuilder that can generate this .INF file for you.

UpdateBuilder download is on the page

I am struggling to get this working.. I am trying to call TWebUpdate.DoUpdate (or DoThreadedUpdate) to update my executable. The documentation is a little vague and short on specific examples. My end goal is to use check in a local folder for newer version of the current exe and if it is present, generate the INF file and use TWebUpdate to replace the executable.

I am generating the following in my INF file:

[update]
localversion=D:\Dropbox\Projects\UpdateTest\Win32\Release\UpdateTest.exe
newversion=2.0.1.1

[files]
count=1

[file1]
url=C:\newapp\UpdateTest.exe

[application]
appupdate=1
appname=D:\Dropbox\Projects\UpdateTest\Win32\Release\UpdateTest.exe
silentrestart=1

My new EXE is C:\newapp\UpdateTest.exe (v2.0.1.1)

My old EXE (which I would like to be updated) is running from D:\Dropbox\Projects\UpdateTest\Win32\Release\UpdateTest.exe (v1.0.1.1)

My TWebUpdate is defined as:

var
wu1: TWebUpdate;

wu1 := TWebUpdate.Create(Self);
wu1.Name := 'wu1';
wu1.Agent := 'TWebUpdate';
wu1.DateFormat := 'dd/mm/yyyy';
wu1.DateSeparator := '/';
wu1.Logging := True;
wu1.LogFileName := 'C:\newapp\WUPDATE.LOG';
wu1.Signature := 'WebUpdate';
wu1.TempDirectory := '.';
wu1.TimeFormat := 'hh:nn';
wu1.TimeSeparator := ':';
wu1.UpdateType := fileUpdate;
wu1.UpdateUpdate := wuuSilent;
wu1.URL := 'C:\newapp\UpdateTest.inf';
wu1.Version := '2.6.0.2';

My WUPDATE.log contains:

27-03-2021 09:43:57 : [968] Start update : Non threaded update --------------------------- (Status:0) (**Error** :0)

27-03-2021 09:43:57 : [966] OS version : Unknown (Status:0) (**Error** :0)

27-03-2021 09:43:57 : [967] IE version : (not found) (Status:0) (**Error** :0)

27-03-2021 09:43:57 : [969] Compiler : D10.1 Berlin (Status:0) (**Error** :0)

27-03-2021 09:43:57 : [970] Installed IDEs : (Status:0) (**Error** :0)

27-03-2021 09:43:57 : [963] Start WebUpdate process with version : 2.6.0.2 (Status:0) (**Error** :0)

27-03-2021 09:43:57 : [915] Download : C:\newapp\UpdateTest.inf (Status:3) (**Error** :0)

27-03-2021 09:43:57 : [926] Update control file found (Status:3) (**Error** :0)

27-03-2021 09:43:57 : [933] Version based update found (Status:3) (**Error** :0)

27-03-2021 09:43:57 : [979] Check versions (Status:3) (**Error** :0)

27-03-2021 09:43:57 : [944] Version check : Version compare of D:\Dropbox\Projects\UpdateTest\Win32\Release\UpdateTest.exe:1.0.1.1 with 2.0.1.1:2.0.1.1 (Status:3) (**Error** :0)

27-03-2021 09:43:57 : [929] New version found : 2.0.1.1 (Status:5) (**Error** :0)

27-03-2021 09:43:57 : [943] Found file update instruction (Status:3) (**Error** :0)

27-03-2021 09:43:57 : [971] Processing file : C:\newapp\UpdateTest.exe[,nv=,nd=,ns=0,nc=-1] (Status:0) (**Error** :0)

27-03-2021 09:43:57 : [979] Check versions (Status:3) (**Error** :0)

27-03-2021 09:43:57 : [915] Download : C:\newapp\UpdateTest.exe (Status:3) (**Error** :0)

27-03-2021 09:43:58 : [948] Finished processing update control file (Status:3) (**Error** :0)

I must be missing something as my EXE is not updating at all?

Thank You very much for any assistance.

There is no appcomps= setting under [application].
It is only when there is a file entry under appcomps that the update is consider as an application update for which the application needs to be restarted.

Thank you. The following INF seems to work as desired.

[update]
localversion=D:\Dropbox\Projects\UpdateTest\Win32\Release\UpdateTest.exe
newversion= 2.0.1.1

[files]
count=1

[file1]
url=C:\newapp\UpdateTest.exe_NEW

[application]
appupdate=1
appname=C:\newapp\UpdateTest.exe_NEW
appcomps=C:\newapp\UpdateTest.exe_NEW
silentrestart=1

One last question... Is it possible to change the name of the "Web Updater" application that comes up asking for permission when elevated priviledges are required for a restart?

I have this working perfectly, but it comes up with a UAC message saying "Web Updater" requires permission to make changes to the system.

If this is running in a bunch of different applications I think it will get confusing as to which one is updating?

Thanks again for giving us such great tools!

OK NOT my last question... After testing this further, it appeared to be working, and when I call DoUpdate() it does launch the new version of my application, but it is not actually replacing the exe, it is just launching the new one and leaving the old one sitting there. Obviously still missing something.

Thanks again for your assistance.

UAC message is by design. When files need to be replaced in folders with limited user permissions, elevation to admin is required to replace the files.

To see why it is not replacing the file, generate the log file and inspect.

Your .INF file is also not clear to me. Your file1 download is the same as the appname you wish to restart? So, it will actually restart the file you put as new file, not the file you want replaced?

Thank you. I understand why the UAC message is coming up, and I have no problem with it. I would just like to know if there is a way for it to come up with the name of my application instead "Web Updater"?

As for the INF file...
What I want to to is replace my running app (D:\Dropbox\Projects\UpdateTest\Win32\Release\UpdateTest.exe) with the new version in C:\newapp\UpdateTest.exe_NEW (or ideally C:\newapp\UpdateTest.exe, I copied it to the _NEW because the documentation gave me the impression it needed to have different name?)

Ultimately, all I want to do is check in a folder for a newer version of my EXE and replace it if there is one.

Thanks again or your help and patience.

  1. You will need to code-sign the spawned updater. If you have a digital signature of your company, contact us by email for the steps to custom sign
  2. Try
    [update]
    localversion=D:\Dropbox\Projects\UpdateTest\Win32\Release\UpdateTest.exe
    newversion= 2.0.1.1

[files]
count=1

[file1]
url=C:\newapp\UpdateTest.exe_NEW

[application]
appupdate=1
appname=UpdateTest.exe_NEW
appcomps=UpdateTest.exe_NEW
silentrestart=1

and if somehow a problem persists, generate the log file again and inspect what happens

Still not quite there. It is coming up with the UAC message, and closing my app, but it is not replacing the exe or restarting it as I am expecting it to?

INF File:

[update]
localversion=D:\Dropbox\Projects\UpdateTest\Win32\Release\UpdateTest.exe
newversion=2.0.1.1

[files]
count=1

[file1]
url=C:\newapp\UpdateTest.new

[application]
appupdate=1
appname=UpdateTest.new
appcomps=UpdateTest.new
silentrestart=1

Log File:

28-03-2021 09:42:38 : [968] Start update : Non threaded update --------------------------- (Status:0) (Error:0)
28-03-2021 09:42:38 : [966] OS version : Unknown (Status:0) (Error:0)
28-03-2021 09:42:38 : [967] IE version : (not found) (Status:0) (Error:0)
28-03-2021 09:42:38 : [969] Compiler : D10.1 Berlin (Status:0) (Error:0)
28-03-2021 09:42:38 : [970] Installed IDEs :  (Status:0) (Error:0)
28-03-2021 09:42:38 : [963] Start WebUpdate process with version : 2.6.0.2 (Status:0) (Error:0)
28-03-2021 09:42:38 : [915] Download : C:\newapp\UpdateTest.inf (Status:3) (Error:0)
28-03-2021 09:42:38 : [926] Update control file found (Status:3) (Error:0)
28-03-2021 09:42:38 : [933] Version based update found (Status:3) (Error:0)
28-03-2021 09:42:38 : [979] Check versions (Status:3) (Error:0)
28-03-2021 09:42:38 : [944] Version check : Version compare of D:\Dropbox\Projects\UpdateTest\Win32\Release\UpdateTest.exe:1.0.1.1 with 2.0.1.1:2.0.1.1 (Status:3) (Error:0)
28-03-2021 09:42:38 : [929] New version found : 2.0.1.1 (Status:5) (Error:0)
28-03-2021 09:42:38 : [943] Found file update instruction (Status:3) (Error:0)
28-03-2021 09:42:38 : [971] Processing file : C:\newapp\UpdateTest.new[,nv=,nd=,ns=0,nc=-1] (Status:0) (Error:0)
28-03-2021 09:42:38 : [979] Check versions (Status:3) (Error:0)
28-03-2021 09:42:38 : [915] Download : C:\newapp\UpdateTest.new (Status:3) (Error:0)
28-03-2021 09:42:38 : [962] Found application component : UpdateTest.new (Status:0) (Error:0)
28-03-2021 09:42:38 : [948] Finished processing update control file (Status:3) (Error:0)
28-03-2021 09:42:38 : [959] Restart app in directory : D:\Dropbox\Projects\UpdateTest\Win32\Release (Status:0) (Error:0)
28-03-2021 09:42:38 : [958] Spawn 26496 L D:\Dropbox\Projects\UpdateTest\Win32\Release\UpdateTest.new " " "C:\Users\natel\AppData\Local\Temp\" UpdateTest.new (Status:0) (Error:0)

Still not quite there. It is coming up with the UAC message, and closing my app, but it is not replacing the exe or restarting it as I am expecting it to?

INF File:

[update]

localversion=D:\Dropbox\Projects\UpdateTest\Win32\Release\UpdateTest.exe

newversion=2.0.1.1

[files]

count=1

[file1]

url=C:\newapp\UpdateTest.new

[application]

appupdate=1

appname=UpdateTest.new

appcomps=UpdateTest.new

silentrestart=1

Log File:

28-03-2021 09:42:38 : [968] Start update : Non threaded update --------------------------- (Status:0) (Error:0)

28-03-2021 09:42:38 : [966] OS version : Unknown (Status:0) (Error:0)

28-03-2021 09:42:38 : [967] IE version : (not found) (Status:0) (Error:0)

28-03-2021 09:42:38 : [969] Compiler : D10.1 Berlin (Status:0) (Error:0)

28-03-2021 09:42:38 : [970] Installed IDEs : (Status:0) (Error:0)

28-03-2021 09:42:38 : [963] Start WebUpdate process with version : 2.6.0.2 (Status:0) (Error:0)

28-03-2021 09:42:38 : [915] Download : C:\newapp\UpdateTest.inf (Status:3) (Error:0)

28-03-2021 09:42:38 : [926] Update control file found (Status:3) (Error:0)

28-03-2021 09:42:38 : [933] Version based update found (Status:3) (Error:0)

28-03-2021 09:42:38 : [979] Check versions (Status:3) (Error:0)

28-03-2021 09:42:38 : [944] Version check : Version compare of D:\Dropbox\Projects\UpdateTest\Win32\Release\UpdateTest.exe:1.0.1.1 with 2.0.1.1:2.0.1.1 (Status:3) (Error:0)

28-03-2021 09:42:38 : [929] New version found : 2.0.1.1 (Status:5) (Error:0)

28-03-2021 09:42:38 : [943] Found file update instruction (Status:3) (Error:0)

28-03-2021 09:42:38 : [971] Processing file : C:\newapp\UpdateTest.new[,nv=,nd=,ns=0,nc=-1] (Status:0) (Error:0)

28-03-2021 09:42:38 : [979] Check versions (Status:3) (Error:0)

28-03-2021 09:42:38 : [915] Download : C:\newapp\UpdateTest.new (Status:3) (Error:0)

28-03-2021 09:42:38 : [962] Found application component : UpdateTest.new (Status:0) (Error:0)

28-03-2021 09:42:38 : [948] Finished processing update control file (Status:3) (Error:0)

28-03-2021 09:42:38 : [959] Restart app in directory : D:\Dropbox\Projects\UpdateTest\Win32\Release (Status:0) (Error:0)

28-03-2021 09:42:38 : [958] Spawn 26496 L D:\Dropbox\Projects\UpdateTest\Win32\Release\UpdateTest.new " " "C:\Users\natel\AppData\Local\Temp" UpdateTest.new (Status:0) (Error:0)

Thank You,

Nathan T. Wild

Senior Developer / Customer Support

Howell Data Systems Inc.

Office 905-761-1712 ext. 2503

Proudly serving great customers for 28 years!

Hi Nathan,

The File 1 section of my INF files (amended to show your exe) are a bit different to yours. Could that be the problem?:.

Thank you... Your response was a little vague, so I created my update INF file as follows, incorporating your additions:

[update]
localversion=D:\Dropbox\Projects\UpdateTest\Win32\Release\UpdateTest.exe
newversion=2.0.1.1

[files]
count=1

[file1]
url=C:\newapp\UpdateTest.new
newversion=2.0.1.1
localversion=UpdateTest.exe
targetdir={app}

[application]
appupdate=1
appname=UpdateTest.new
appcomps=UpdateTest.new
silentrestart=1

Your example is missing the [update] and [application] sections? Are these not required? Either way, when I run the update with the above file it does come up with the UAC confirmation and closes my application. It does not replace the EXE or restart it.

I tried with an INF file based on yours:

[files]
count=1

[file1]
url=C:\newapp\UpdateTest.new
newversion=2.0.1.1
localversion=UpdateTest.exe
targetdir={app}

..and it doesn't do much of anything ;)

Log generates:

30-03-2021 17:48:51 : [968] Start update : Non threaded update --------------------------- (Status:0) (Error:0)
30-03-2021 17:48:51 : [966] OS version : Unknown (Status:0) (Error:0)
30-03-2021 17:48:51 : [967] IE version : (not found) (Status:0) (Error:0)
30-03-2021 17:48:51 : [969] Compiler : D10.1 Berlin (Status:0) (Error:0)
30-03-2021 17:48:51 : [970] Installed IDEs :  (Status:0) (Error:0)
30-03-2021 17:48:51 : [963] Start WebUpdate process with version : 2.6.0.2 (Status:0) (Error:0)
30-03-2021 17:48:51 : [915] Download : C:\newapp\UpdateTest.inf (Status:3) (Error:0)
30-03-2021 17:48:51 : [926] Update control file found (Status:3) (Error:0)

I was just referring to the File1 section; you still need all the other sections as per your original inf file.

Thanks William, that's what I thought. The best I can get here is a UAC prompt, and my application getting closed. No replace, no restart?

Ok, can't think of anything else at the moment - sorry.