Error message:

The following unexpected error occurred:
Unable to install Windows Installer MSI file

Workaround:

You will need access to the SQL Server 2005 SP1 package.  First, copy/paste the following script into notepad and save it as "RepairSP1Source.js".

if( WScript.Arguments.Length < 1 )

{

    WScript.Echo( "Usage: RepairSP1Source.js \"<path to extracted SP1 files>\"" );

    WScript.Quit( 1 );

}

 

var filesystem = new ActiveXObject( "Scripting.FileSystemObject" );

var newSource = WScript.Arguments( 0 );

 

if( !filesystem.FolderExists( newSource ) )

{

    WScript.Echo( "The path to the extracted SP1 package does not exist.  Please correct the path and run the tool again." );

    WScript.Quit( 1 );

}

 

var installer = WScript.CreateObject( "WindowsInstaller.Installer" );

 

// Look for MSPs at the extracted location

EnumerateMSPs( newSource );

 

function EnumerateMSPs( extractedSp1PatchPath )

{

    var folder = filesystem.GetFolder( extractedSp1PatchPath );

    var fileEnum = new Enumerator( folder.Files );

    for( ; !fileEnum.atEnd(); fileEnum.moveNext() )

    {

        var nextFile = fileEnum.item();

       

        if( filesystem.GetExtensionName( nextFile.Name ) == "msp" )

        {

            WScript.Echo( "Found patch located at: " + nextFile.Path );

            var extractedSp1PatchSummaryInfo = installer.SummaryInformation( nextFile.Path );

            // Retrieve the PatchCode from the SummaryInformation

            var extractedSp1PatchCode = new String( extractedSp1PatchSummaryInfo.Property( 9 ) ).substring( 0, 38 );

 

            // Look to see if we need to repair the cached MSP for this Patch

            RepairCachedMSP( extractedSp1PatchCode, nextFile.Path );

            WScript.Echo();

        }

    }

 

    // Now look in subfolders for MSPs

    var folderEnum = new Enumerator( folder.SubFolders );

 

    for( ; !folderEnum.atEnd(); folderEnum.moveNext() )

    {

        var nextFolder = folderEnum.item();

       

        EnumerateMSPs( nextFolder.Path );

    }

}

 

function RepairCachedMSP( extractedSp1PatchCode, extractedSp1PatchPath )

{

    var sp1Patch = null;

    var cachedSp1PatchFileName = null;

 

    WScript.Echo( "Attempting to repair the local cache for PatchCode \"" + extractedSp1PatchCode + "\"" );

 

    // Enumerate all products installed on the machine to see if any have been patched by

    // this MSP

    var products = installer.ProductsEx( "", "", 4 );

 

    // Look for the first product that is patched with this MSP.

    for( var x = 0; (sp1Patch == null) && (x < products.Count); x++ )

    {

        var nextProduct = products.Item( x );

        var nextProductPatches = installer.PatchesEx( nextProduct.ProductCode, "", 4, 1 );

       

        for( var y = 0; (sp1Patch == null) && (y < nextProductPatches.Count); y++ )

        {

            var nextProductPatch = nextProductPatches.Item( y );

            var nextPatchURL = nextProductPatch.PatchProperty( "MoreInfoURL" );

            var nextPatchURLString = new String( nextPatchURL );

           

            // See if this patch is SP1 and if it matches the PatchCode of what the user

            // extracted to the hard drive.

            if( ( nextPatchURLString.indexOf( "kbid=913090" ) != -1 )

                    && ( extractedSp1PatchCode == nextProductPatch.PatchCode ) )

            {

                cachedSp1PatchFileName = nextProductPatch.PatchProperty( "LocalPackage" );

 

                // Only re-cache if the MSP is missing

                if( !filesystem.FileExists( cachedSp1PatchFileName ) )

                {

                    sp1Patch = nextProductPatch;

                }

            }

        }

    }

 

    if( !cachedSp1PatchFileName )

    {

        WScript.Echo( "No action can be taken as the patch has not been applied on the local machine." );

    }

    else

    {

        if( sp1Patch == null )

        {

            WScript.Echo( "No action will be taken since the provided SP1 patch appears to exist locally." );

        }

        else

        {

            var extractedSp1Patch = filesystem.GetFile( extractedSp1PatchPath );

 

            WScript.Echo( "Re-caching patch for the product code \"" + sp1Patch.ProductCode

                + "\" and patch \"" + sp1Patch.PatchCode + "\" to \"" + cachedSp1PatchFileName + "\"" );

            extractedSp1Patch.Copy( cachedSp1PatchFileName );

 

            var updatedSp1Patch = filesystem.GetFile( cachedSp1PatchFileName );

            var currentAttributes = updatedSp1Patch.Attributes;

           

            // If the file isn't read-only mark it as such.

            if( ( currentAttributes & 1 ) == 0 )

            {

                updatedSp1Patch.Attributes = (currentAttributes | 1 );

            }

        }

    }

 

}

 

The SP1 package when run with the "/X" switch will popup a dialog that allows you to extract out the files to a location on your local disk.  You are going to need to run this and save off the SP1 files to a path on your machine.  Once you do that, you run the script above and pass to it the path of where the files were extracted.  Then you should be able to apply SP2.  The steps will look like this:

  1. SQLServer2005SP1-KB913090-x86-ENU.exe /X
  2. cscript RepairSP1Source.js "<path to SP1 files>"
  3. Run SP2 again

RepairSP1source.txt (4.74 KB)

Source: http://forums.microsoft.com/msdn/showpost.aspx?postid=1249824&siteid=1&sb=0&d=1&at=7&ft=11&tf=0&pageid=5