Update EXE File

  • Thread starter Thread starter Wayne Wengert
  • Start date Start date
W

Wayne Wengert

I want to have my application (VB.NET) check a table on an SQL server to see
if there is a newer version released and, if so, download and install the
new version. I know how to setup the database table but I am looking for
ideas on how to handle the update. Since the application is running, I can't
just replace that EXE. The only way I've thought of is to have a small front
end app that does the version check and download if needed? I'm not sure if
there are problems with doing a download/replace and then calling then
immediately executing that file.

I also am considering adding some way to save the replaced EXE so the user
could do a roll-back.

Has anyone implemented something like this? Any suggestions on the best way
to do it?

Wayne
 
I haven't done it, but it seems like the easiest way would be to:

1. Call the update as a separate .exe from the main.exe
2. Shut down the main.exe
3. Update the main and any dll files
4. Restart the main.exe
5. Shut down the update.exe

If the update.exe needs updated, simply have it checked first and replaced
from the main.exe.
 
I've done this by creating a new .msi installation file for the upgrade.

What I do is have a bit of code that runs as the the application starts that
checks the version no - I do this in a similar way to that way you do it.

If an update is required, then I copy the msi file to the local PC.

At this stage I warn the user that an upgrade is required and ask then to
click ok to continue.

I then "run" the msi using the following code:

MsgBox("New DMS Update to Install, close all DMS Windows and click ok to
install", MsgBoxStyle.OKOnly, "DMS Update")

Dim pr As New Process

pr = New Process

Dim prinfo As New ProcessStartInfo

With prinfo

..FileName = "c:\dms\dms.msi"

..UseShellExecute = True

End With

pr.Start(prinfo)



and then kill the running process using the following:

' Kill all processes

For Each pr In
Process.GetProcessesByName(Process.GetCurrentProcess.ProcessName)

pr.Kill()

Next



This seems to work for me.



Regards

Simon
 
Thanks Simon;

That sounds like a good approach. I'll give it a try.

In creating he msi for just the upgrade (I never thought of that) I am
guessing that you create a new VSNET solution and simply drop a copy of the
new exe in there and then build the distribution package?

Wayne
 
You create a Windows Installer Solution as part of your project..

This will take your main project as it's starting point and build an MSI
file for you to install with on client PC's.

Make sure you set the property "Detect NewerInstalledVersion" to True and
"RemovePreviousVersions" to true otherwise you will get errors about
"application already installed". Also, increment the version property of
the installer - this will prompt you if you want to update the product and
update codes (which you should). This should then allow you to update the
msi each time.

As far as checking that the correct version number is installed, you can
either manually include a file in with your installer with the version no in
or do as I do, and add the version number that you use in the installer
project to create a registry entry - to do this, right click the installer
project and "view registry". Create a path to the registry key that you
want and set this to [ProductVersion]

I actually read this registry key in from within the application so that I
know exactly what version I'm running (this is the version as manually typed
into the installer project rather than individual dll/executeble versions).

You may find all of this a little difficult to understand if you are not
familiar with creating installers in VS.Net (it's not all that intuitive and
the documentation relating to it is not brilliant!). Hopefully, I've given
you a few pointers to get you going.

regards
Simon
 
Thanks for the addition information. Actually, I have built some install
packages using VSNET (as you say - not the greatest). I don't want the user
to have to do a full re-install as the msi is over 50MB (Crystal Reports and
several other components). I usually just replace the EXE file (about 1 MB).
I just try to adapt your process to do that.

Thanks again for all the help

Wayne

Simon Verona said:
You create a Windows Installer Solution as part of your project..

This will take your main project as it's starting point and build an MSI
file for you to install with on client PC's.

Make sure you set the property "Detect NewerInstalledVersion" to True and
"RemovePreviousVersions" to true otherwise you will get errors about
"application already installed". Also, increment the version property of
the installer - this will prompt you if you want to update the product and
update codes (which you should). This should then allow you to update the
msi each time.

As far as checking that the correct version number is installed, you can
either manually include a file in with your installer with the version no in
or do as I do, and add the version number that you use in the installer
project to create a registry entry - to do this, right click the installer
project and "view registry". Create a path to the registry key that you
want and set this to [ProductVersion]

I actually read this registry key in from within the application so that I
know exactly what version I'm running (this is the version as manually typed
into the installer project rather than individual dll/executeble versions).

You may find all of this a little difficult to understand if you are not
familiar with creating installers in VS.Net (it's not all that intuitive and
the documentation relating to it is not brilliant!). Hopefully, I've given
you a few pointers to get you going.

regards
Simon
Wayne Wengert said:
Thanks Simon;

That sounds like a good approach. I'll give it a try.

In creating he msi for just the upgrade (I never thought of that) I am
guessing that you create a new VSNET solution and simply drop a copy of
the
new exe in there and then build the distribution package?

Wayne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top