0
votes

I have an windows service running that updates another windows service. It does this by uninstalling the currentversion and then installing the newer one. We do this using the original msi installers and msiexec with Process.Start().

Process msiexec = new Process();
msiexec.StartInfo.FileName = "msiexec";
msiexec.StartInfo.Arguments = "/quiet /i \"" + msiFileName + "\" /l*v \"" + msilogfile + "\"";

if (!msiexec.Start())
....etc... error handling code and such...

Uninstalling goes fine, so thats no problem. Installing, seems to go fine as well. I output the msi install log. And in the log, it says it succesfully installed.

I then reboot the computer, and on startup, Windows itself runs the installer again? It then complains that the service already exists of course and it all breaks...

What could be the reason that Windows decides to run the installer at startup?

Important to note here: If I manually install the new version, it works and windows does not try to install it on startup. So it has to do with msiexec maybe? Some permission thing?

2
Check the PendingFileRenameOperations value under the HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager key after your next test to see if there are any entries. I would suspect that the entire install is not being completed when using the service, so the MSI is accessed again by the OS after the reboot to finish the job. - slugster
Ok, I checked, but the key is empty. After a second reboot, it started again, this time as well as complaining that the service already exists. It also gave the error that it could not find the .InstallState file anymore. But I guess this is out of scope, because it's kind of messed up by now. - Gonzalioz
What do you see in your event viewer? Any information about something missing? Also, would it be possible to upload your installation log somewhere? - Kiran Hegde
At the time of installation, there is nothing strange in the eventviewer. However, on startup, before the windows runs the msiinstaller again. I see these warnings: Detection of product '{347C9271-FA9D-4FA5-B447-776D168BB9D6}', feature 'DefaultFeature' failed during request for component '{2BC8DA2C-6B6B-0B04-54F1-7BBD6C587269}' Detection of product '{347C9271-FA9D-4FA5-B447-776D168BB9D6}', feature 'DefaultFeature', component '{605E6584-610F-4DAE-4C09-BD9495105253}' failed. The resource 'HKEY_CURRENT_USER\Software\MyCompany\MyProduct\Something\events' does not exist. - Gonzalioz
Sorry, I don't know how to put newlines in the comment box. Could those warnings cause Windows to decide to run the installer? - Gonzalioz

2 Answers

1
votes

This is probably a repair. Check the Application Event Log for MsiInstaller entries that mention missing components. It'll happen if Windows thinks the installed product is damaged.

I suspect the reason you see the error about the service already installed is that you are using an Installer class custom action to install the service, and it will run again on repair and give you the error about already installed. You'd see the same "already installed" error if you right-clicked the MSI and chose repair, or did repair from Programs&Features.

To prevent this add a condition of Not Installed to the install custom action that installs the service, then it will run only on an install and not on a repair.

-1
votes

You either miss a registry entry at the location it is pointing you to, or your applications shouldn't be looking for that registry entry in the first place.

There are a couple of ways to fix this issue, you can read about it in this article.

Let me know weather it helps!