Robert's SQL Blog

My thoughts on SQL Server, PowerShell and Microsoft products in general.
@rhartskeerl
Follow me on Twitter

Unable to install Windows Installer MSP file

Sometimes when you patch SQL Server you get an error. Most times when you get an error it’s your own fault, or better someone else’s. I had such an experience recently and wanted to share some information on why this is happening and of course how to resolve it. There is already a great blog post on the subject. Although the error number is different it does apply; http://blogs.msdn.com/b/sqlserverfaq/archive/2009/01/30/part-1-sql-server-2005-patch-fails-to-install-with-an-error-unable-to-install-windows-installer-msp-file.aspx

So what’s the problem. In this case a SQL 2005 installation was upgraded to SP1 – SP2 – CUSomething and needed to be patch to the next CU. But applying this CU failed with the error in this title. First thing to check with installer errors is the summary.txt file in the Bootstrap\Log folder. So here is an excerpt of my log file.

Product Installation Status
Product                   : SQL Server Database Services 2005 (MSSQLSERVER)
Product Version (Previous): 3077
Product Version (Final)   :
Status                    : Failure
Log File                  : C:\Program Files\Microsoft SQL Server\90\Setup Bootstrap\LOG\Hotfix\SQL9_Hotfix_KB976952_sqlrun_sql.msp.log
Error Number              : 1635
Error Description         : Unable to install Windows Installer MSP file

As this is a summary there is not much detail about the actual error. All you can tell I’m coming from SQL 2005 build 3077. Luckily the location of the detailed log is mentioned. Now, here are some lines of interest from that file.

MSI (s) (A4:A8) [13:20:30:996]: Opening existing patch ‘C:\WINDOWS\Installer\3d482d64.msp’.
MSI (s) (A4:A8) [13:20:30:996]: Note: 1: 2203 2: C:\WINDOWS\Installer\3d482d64.msp 3: -2147287038
MSI (s) (A4:A8) [13:20:30:996]: Couldn’t find local patch ‘C:\WINDOWS\Installer\3d482d64.msp’. Looking for it at its source.
MSI (s) (A4:A8) [13:20:30:996]: Resolving Patch source.
MSI (s) (A4:A8) [13:20:30:996]: User policy value ‘SearchOrder’ is ‘nmu’
MSI (s) (A4:A8) [13:20:30:996]: User policy value ‘DisableMedia’ is 0
MSI (s) (A4:A8) [13:20:30:996]: Machine policy value ‘AllowLockdownMedia’ is 0
MSI (s) (A4:A8) [13:20:30:996]: SOURCEMGMT: Media enabled only if package is safe.
MSI (s) (A4:A8) [13:20:30:996]: SOURCEMGMT: Looking for sourcelist for product {4A35EF4A-D868-4B15-A84D-3E8925AA9558}
MSI (s) (A4:A8) [13:20:30:996]: SOURCEMGMT: Adding {4A35EF4A-D868-4B15-A84D-3E8925AA9558}; to potential sourcelist list (pcode;disk;relpath).
MSI (s) (A4:A8) [13:20:30:996]: SOURCEMGMT: Now checking product {4A35EF4A-D868-4B15-A84D-3E8925AA9558}
MSI (s) (A4:A8) [13:20:30:996]: SOURCEMGMT: Media is enabled for product.
MSI (s) (A4:A8) [13:20:30:996]: SOURCEMGMT: Attempting to use LastUsedSource from source list.
MSI (s) (A4:A8) [13:20:30:996]: SOURCEMGMT: Trying source e:\01dddf5653431568a309\HotFixSQL\Files\.
MSI (s) (A4:A8) [13:20:30:996]: Note: 1: 2203 2: e:\01dddf5653431568a309\HotFixSQL\Files\sqlrun_sql.msp 3: -2147287037
MSI (s) (A4:A8) [13:20:30:996]: SOURCEMGMT: Source is invalid due to missing/inaccessible package.
MSI (s) (A4:A8) [13:20:30:996]: Note: 1: 1706 2: -2147483647 3: sqlrun_sql.msp
MSI (s) (A4:A8) [13:20:30:996]: SOURCEMGMT: Processing net source list.
MSI (s) (A4:A8) [13:20:30:996]: Note: 1: 1706 2: -2147483647 3: sqlrun_sql.msp
MSI (s) (A4:A8) [13:20:30:996]: SOURCEMGMT: Processing media source list.
MSI (s) (A4:A8) [13:20:32:011]: SOURCEMGMT: Resolved source to: ‘sqlrun_sql.msp’
MSI (s) (A4:A8) [13:21:27:667]: Note: 1: 1314 2: sqlrun_sql.msp
MSI (s) (A4:A8) [13:21:27:667]: Unable to create a temp copy of patch ‘sqlrun_sql.msp’.
MSI (s) (A4:A8) [13:21:27:667]: Note: 1: 1708
MSI (s) (A4:A8) [13:21:27:667]: Note: 1: 2729
MSI (s) (A4:A8) [13:21:27:667]: Note: 1: 2729
MSI (s) (A4:A8) [13:21:27:683]: Product: Microsoft SQL Server 2005 — Installation failed.

There is one thing that you can notice here. Apparently 3d482d64.msp and file sqlrun_sql.msp are missing. One file from C:\Windows\Installer and one apparently from the temporary folder we are installing the hotfix from. The first answer is correct, the second not. During extraction of the hotfix I noticed the folder getting created and it was different then the one listed here. So, a file is missing. All you  need to find out is which file.

Now there are a couple of leads to get you to the actual missing file. It’s not sqlrun_sql.msp. This file is included with all packages and the 3d482d64 is actually a randomly renamed version of sqlrun_sql.msp at the time the patch was applied. We need to know what the original package was.

A search for the guid inside the registry failed (4A35EF4A-D868-4B15-A84D-3E8925AA9558). It turns out the installer saves the guid in a different format. There is some documentation on this. Basically the characters are reversed by sequence. The complete string in my case became A4FE53A4868D51B48AD4E39852AA5985 which can be found in the registry. Another key from the package was the instance key (this is one of the first guids in the logfile). With the same conversion trick you can find that in the registry under the key HKLM\Software\MicrosoftWindows\CurrentVersion\Installer\UserData\S-1-5-18\Products\<GUID>. This is the key for the installed instance, in my case SQL Server 2005. More interesting, underneath it is a subkey Patches with a value of the earlier guid (4A35EF4A etc.). One of the values there stated SQL Server 2005 Service Pack 2.

In the post mentioned earlier it stated to copy the correct msp file with the correct name to Windows\Installer. That works if you are only upgrading one part of SQL, eg the engine. If you are also updating Reporting Services or Integration Services more files need to be copied. What I did was download the servicepack 2 files, exctracted them by running the setup with the /x parameter. When asked for the path, I provided the path from the logfile (e:\01dddf5653431568a309). After the package was extracted I ran the hotfix that failed before again and it succeeded.

Lesson learned is to never throw away files in system folders. We all know this but in this case diskspace was getting tight and someone decided to remove old files. Even then, get bigger disks. Again, look at this post: http://blogs.msdn.com/b/sqlserverfaq/archive/2009/01/30/part-1-sql-server-2005-patch-fails-to-install-with-an-error-unable-to-install-windows-installer-msp-file.aspx. It’s somewhat different from my problem but the steps outlined are quite alike. There are some good resources mentioned there as well.