Auto-update your Windows Service with Google Omaha

Say you are developing a Windows Service and want to be able to automatically update it on your users' PCs. Then this post shows how you can use Google's open source framework Omaha to achieve this goal.

What is Google Omaha?

Omaha is the technology which Google use to keep applications such as Chrome up to date. It works as follows: When you install Chrome, Omaha is installed as a separate application alongside Chrome. You can see this in your Program Files (x86) folder:

Note the Google/Update folder. This is where Omaha (also called "Google Update") resides. But there are other places where it shows up on your system.

Omaha works by periodically checking for updates in the background. This process is kicked off via Windows' Task Scheduler. Once you install a Google product such as Chrome, you will find Omaha's entries there:

In the screenshot above, you see that Omaha checks for updates every day at 4:20 PM.

When you compare it to other update frameworks, Omaha is without a doubt the most stable, powerful and secure. On the one hand, this is because it comes from Google, one of the most respected software companies in the world. On the other hand, it stems from Omaha's requirements and its huge install base. Updates are a critical security feature of every browser. Google thus have to make sure that Omaha runs well on each of the hundreds of millions (if not billions) of machines where Chrome is installed.

Updating a Windows Service

One thing that is nice about Omaha is that it is especially well-suited for updating Windows Services. There are two main reasons for this: First, as explained above, Omaha's default mode of operation is to run silently in the background. This is exactly how Windows Services operate. Second, Omaha runs in parallel to your application. This reduces your effort to integrate Omaha, and also fits perfectly with the asynchronous nature of Services.

So how, then, do you integrate Omaha into your Windows Service? Omaha works purely on the basis of .exe or .msi files. Say you have an installer for your application with one of these extensions. Let us also assume that this installer contains logic that handles the case where an old version of your Service is already running. In this scenario, the installer likely stops your Service, removes the previous version, then installs the update. If your installer can moreover run silently on the command-line, then all you need to do to integrate Omaha into your application is to set some registry keys. Once you have done this, you can release new versions simply by uploading their installer to the update server.

Unfortunately, integrating Omaha into your Service is only one step. Omaha also requires two other components that are harder to come by. First, you need a server that speaks the Omaha protocol and distributes your updates. There is an open source implementation, but it is not straightforward to set up. Second, you need an update client that runs on your users' PCs and fetches updates from your server. This sounds simple but is actually surprisingly difficult. Google's open source implementation of the client hard-codes Google's values such as their update server URL, the names of binaries such as GoogleUpdate.exe, and many Google-specific identifiers. To be able to use Omaha for your applications, you must create a fork of Google's C++ client implementation. In our experience, many companies struggle with this step. And those that complete it often end up with subtly broken implementations.

This is where we come in. As an agency, we specialize in helping companies set up and maintain automatic update systems based on Google Omaha. Because we have years of experience working with the technology, we can often do in hours what would take our clients weeks. At the same time, we are able to avoid costly pitfalls that people often run into when introducing Omaha for their products.

If you would like to learn more about how Omaha works, you can take a look at our Google Omaha Tutorial. Or you can send us a message if you like. We typically reply within one business day.

Summary

Omaha is the update framework which Google use to update applications such as Chrome. Omaha runs on hundreds of millions (if not billions) of devices. This widespread use, and the fact that an esteemed company such as Google is behind it, makes Omaha the gold standard for update systems.

When it comes to updating Windows Services, Omaha's asynchronous nature makes it an especially good fit. Integrating Omaha into an application is usually easy. The harder steps are to obtain the necessary server and to fork Google's implementation of the client so it can be used to update your (and not Google's) applications. We are an agency that specializes in helping companies with this. If you would like to learn more about Omaha, or how we might be able to help, just send us a message. We will usually get back to you within one business day.