22

What is the best way to update an MSI installation over the internet?

ClickOnce doesn't support MSIs.

I need the update to occur automatically over the internet, in the same manner as Windows updates occur.

Ideally, I would want my application to automatically detect that an update is available and download it and install it.

Answers should only deal with MSIs installations. I don't mind if there needs to be a Windows Service installed to monitor for updates.

CJ7
  • 22,579
  • 65
  • 193
  • 321

5 Answers5

17

Here's what I've done for a customer recently:

The UI is running as the logged on User.

The service is running as System. The service checks for content and downloads it to a temp directory. It then advertises the MSI using the /JM command. The installer can now be installed by the non-priviledged user.

The service sends an IPC message to the application saying that it's time to install. The application kicks off the installer passing it a flag that indicates to restart the application. The application the quits releasing the locked files.

At the end of the installer the flag causes the installer to relaunch the application.

Also take a look at the wuw4 library. It helps in creating a lot of this solution.

This is a complex pattern but works very well. I own a company that can assist you in making this solution. :)

Christopher Painter
  • 54,556
  • 6
  • 63
  • 100
  • A few questions: Is it necessary to have a Service? Couldn't the app just check for updates on startup? What temp folder will a Service have access to? – CJ7 Feb 15 '12 at 01:07
  • 1
    Due to security considerations and how Windows Installer works it's best to have an elevated process that can create a temp directory where the non-priv user only has read access and the advertise the installation from there. The non-priv end user process can then launch the installation and it'll work. If the non-priv user checks for updates on startup this poses elevation problems down the road. – Christopher Painter Feb 15 '12 at 01:28
  • If the application is very lightweight and doesn't require admin privs to install then you might want to consider ClickOnce. But if it's a Per-Machine installation that any non-priv user will need to upgrade then this pattern with MSI is what you'll need. – Christopher Painter Feb 15 '12 at 01:29
  • The problem is that it's a VB6 app that uses .NET components, so that makes ClickOnce difficult. I do also like the MSI features such as self-heal. – CJ7 Feb 15 '12 at 01:40
  • Also, will the Service cause undesirable elevation prompts as is suggested in this answer? http://stackoverflow.com/a/7396926/327528 – CJ7 Feb 15 '12 at 01:44
  • I assume they are COM Visible components. You can use RegFree COM manifests to make them visible to the VB6 app without writing to the registry. Also if you google for "vb6 clickonce" you'll see some articles discussing packaging up legacy unamanged applications with clickonce. Don't get me wrong, I'm a fan of MSI not ClickOnce but if your application is small enough for ClickOnce to work it'll basically get you the self-heal and auto update for a lot less work. The self-heal is different in that the VSTO manifest files will be looking for files in the clickonce cache and DL if needed. – Christopher Painter Feb 15 '12 at 01:45
  • No, because the service is already elevated and advertising the installation ( blessing it as a manged install if you will ) the user will transition from the UI to Execute sequence without any UAC prompting. – Christopher Painter Feb 15 '12 at 01:46
  • And how does the Installshield update service fit in this picture in terms of feasibility? – CJ7 Feb 15 '12 at 01:54
  • It's similar. They are providing the canned update agent and back end service ( servers ) along with detailed reporting on user usage data. It wasn't clear from your original questions and tags if you are using InstallShield or something else to make your MSI. IF you are using InstallShield you'd might want to ask Michael Urman above as he's a developer on the IS team. – Christopher Painter Feb 15 '12 at 02:08
  • Well, I did use IS to create the MSI because I needed to auto-detect the dependencies. I also don't know where I would have got all the required redistributables/modules without IS. I would prefer not to pay any more money to Flexera so I would be happy to create an update service myself. If it is just a matter of advertising the MSI then it sounds do-able. – CJ7 Feb 15 '12 at 02:27
  • Where can I find out about this concept of 'advertising' the installation? If the installation is advertised, will the new version be installed when the app icon is double-clicked in a kind of self-heal fashion? – CJ7 Feb 20 '12 at 11:44
  • http://blog.deploymentengineering.com/2006/10/implementing-auto-updating.html http://support.microsoft.com/kb/259459 – Christopher Painter Feb 20 '12 at 17:54
  • Just wanted to say this works great. Managed to implement it without the wuw4 library. Thanks Christopher! – Edgar Mar 29 '16 at 06:34
  • Hi Christopher, Could you clarify with sample code. I am in the same issue and i want to fix it – yo2011 May 17 '16 at 19:11
  • any response Christopher – yo2011 May 18 '16 at 09:53
3

You can use the msiexec utility. Here you can find an example.

Ciprian
  • 3,533
  • 1
  • 18
  • 22
1

Windows Installer does not support automatic updates, nor will it handle their delivery. The company for which I work sells a product targeting updates and more.

Michael Urman
  • 15,737
  • 2
  • 28
  • 44
1

Here is what I would usually do (its just a concept of how I update my program):

  • Use Advanced Installer Or any other MSI installer/packer supports Command Line to pack the files of your updated program. You need to set the parameters correctly and test it before you proceed to next step.

  • Go to Visual Studio -> select your project then -> properties -> Build Events.

  • In "Post-Build event command line" textbox enter the command line parameters you created earlier then click ok.

  • Now whenever you build your project, visual studio will automatically pack your files with MSI installer/packer.

  • Last step is to look for FTP Client works from command line also.

  • Set the correct parameters and add it to "Post-Build event" after the previous one.

  • Now if you build your project with visual studio again. Your files will be automatically packed then uploaded to your server.

Now your files should be fully updated on the server and you don't need to worry about that anymore. That's the best solution I've found, I'm using it and it works like a charm...

EDIT: one more thing, you can also add a simple routine to look for newer updates on server inside your program. something like checking the MD5 hash of the files or the files versions etc. once the routine finds a new update it should prompt that to the user and then you can tell the user to download the latest update etc...

Desolator
  • 22,411
  • 20
  • 73
  • 96
  • Sorry, I didn't mean to automatically send the package to a server. I mean that a user will receive automatic update of product. – CJ7 Feb 20 '12 at 02:26
  • yea and you must update your files on the server first... then read the edit part. you should create "update" checking routine to check for newer versions on the server.... – Desolator Feb 20 '12 at 03:39
0

Did you check App-Virtualization? http://www.microsoft.com/en-us/windows/enterprise/products-and-technologies/virtualization/default.aspx

This is a great way to stream your executables/msi to the clients while ensuring it always runs the latest msi.

whihathac
  • 1,741
  • 2
  • 22
  • 38
  • Can you explain what that is? I have tried reading that website but can't make any sense of it. – CJ7 Feb 20 '12 at 02:23
  • Can you have a look at this - http://blog.augustoalvarez.com.ar/2012/01/31/app-v-a-quick-glance-to-server-app-v-and-sequencing-server-applications/ – whihathac Feb 20 '12 at 13:46