views:

603

answers:

4

We are working on an update system for our software. The updater should in the background as a service, and when an update is available, downloads and installs it. We need the service to install the update since the msi requires elevation to run, but some of our clients will be restricted users.

The MSI is a WIX MSI and does a Major Upgrade when run. The problem is, the update does not seem to work when ran from our service. I can see msiexec run, and it returns successfully, but seems to make no changes to the system. The same command, when run from my user account works as expected.

Is there some caveat to running msiexec from a Local System service?

We are simply doing:

string arguments = "/i /quiet /lv*x " + pathToLogFile;   
System.Diagnostics.Process.Start("msiexec.exe", arguments);
+2  A: 

If your service is a windows service then do a follow steps :

1.Open properties of your service in Services console.

2.Go to Log On tab

3.Set there an account that has rights to update the system (yours or specially created for this purpose)

  1. Restart the service

In this case, the service will be runned with proper rights and can do updates.

Andrey Tagaew
I think we can make this work. Thanks!
Jarrod
A: 

Please do not design your software to install yet another software update service. It is simply inefficient and wrong, as it slows down the boot time and eats system resources for a process that is mostly doing nothing.

Create a small "application launcher" executable instead, which has the option of checking for updates before running the application. This also allows you to give users the option to "upgrade before launching" or "upgrade when exiting" should you so desire.

If you absolutely must have a Windows service then be sure to have it start delayed on boot and to shut itself down after checking for updates. The client process can start the service when it is launched.

As for your specific problem, most likely the update is being installed under a different user account. Starting the process with the users credentials should resolve the problem.

Morten Mertner
+1 for "not another service"
slugster
Good points, but your solution won't solve the admin permission / elevation problem.
0xA3
It is possible for a restricted process to start a service with higher privileges, or the restricted process could display an UAC dialog (i.e. request additional privileges for the update).
Morten Mertner
Yes, write a executable running in user session is better. Once a user log in this exe can ask the service whether new things need to be installed. That's how SCCM client prompts me to install critical updates.
Lex Li
Thanks for the suggestion, but this isn't a program for use by the general public. I hate the idea of additional services running, but it is simply unacceptable to require an administrator to go around to hundreds of machines on a factory floor every time an update is pushed. Furthermore, one of the applications the updater updates runs all the time, so it will not work to make it check for update on start, as it will rarely be started. Your comment focuses more on criticizing a solution to a problem you know nothing about, rather than answering the question I asked.
Jarrod
A: 

I also had the same task described above and I found that if program was installed for ALL users, running msiexec would work from Service which is running under SYSTEM account. So to make this work, you will have to install for ALL users. In my case, I specified msxexec command as follows when the program is first installed.

msiexec /i setup.msi ALLUSERS="1"

Once this is done, you can just upgrade the program from Service without any issue.

YEH
A: 

You may need to use the REINSTALLMODE parameter that allows you to control the upgrade. If they are not provided, the installation may silently fail to upgrade your app (or at least that's what I've found, though I'm still a little unsure whether the same behaviour applies under System.Diagnostics.Process.Start):

msiexec.exe /i /quiet yourinstaller.msi REINSTALL=All REINSTALLMODE=vomus

See here for more info on the various flags that you can pass to msiexec.exe.

Andrew Matthews