Using pkgmgr to install IIS 7

4.5k views Asked by At

I am using following custom action to install IIS 7 using .msi if its not already installed on targeted system. I am getting following errror and my installation fails. I have used quite a few CA in my msi and all work well. However for this one I am not able to figure out what the problem could be? Executing this command directly on cmd prompt works perfect. Can anyone provide any suggestions as to what am i doing wrong? Please advice

Targeted OS: Windows 7 -32 bit

CustomAction Code:

<Property Id="INSTALLIISPROP" Value="[SystemFolder]"></Property>
  <CustomAction Id="InstallIISCA" Return="check" Property="INSTALLIISPROP" Execute="deferred" ExeCommand=" start /w pkgmgr /iu:IIS-WebServerRole;IIS-WebServer;IIS-CommonHttpFeatures;IIS-StaticContent;IIS-DefaultDocument;IIS-DirectoryBrowsing;IIS-HttpErrors;IIS-HttpRedirect;IIS-ApplicationDevelopment;IIS-ASPNET;IIS-NetFxExtensibility; IIS-ASP;IIS-ISAPIExtensions;IIS-ISAPIFilter;IIS-HealthAndDiagnostics;IIS-HttpLogging;IIS-LoggingLibraries;IIS-RequestMonitor;IIS-HttpTracing;IIS-CustomLogging;IIS-Security;IIS-WindowsAuthentication;IIS-RequestFiltering;IIS-IPSecurity;IIS-Performance;IIS-HttpCompressionStatic;IIS-WebServerManagementTools; IIS-ManagementConsole;IIS-ManagementScriptingTools;IIS-ManagementService;WAS-WindowsActivationService;WAS-ProcessModel;WAS-NetFxEnvironment;WAS-ConfigurationAPI;NetFx3"></CustomAction><InstallExecuteSequence><Custom Action="InstallIISCA" Before="InstallFinalize"><![CDATA[NOT Installed AND IISMAJORVERSION]]></Custom></InstallExecuteSequence>

Error from my log file:

Error 1721. There is a problem with this Windows Installer package. A program required for this install to complete could not be run. Contact your support personnel or package vendor. Action: InstallIISCA, location: [SystemFolder], command: start /w pkgmgr /iu:IIS-WebServerRole;IIS-WebServer;IIS-CommonHttpFeatures;IIS-StaticContent;IIS-DefaultDocument;IIS-DirectoryBrowsing;IIS-HttpErrors;IIS-HttpRedirect;IIS-ApplicationDevelopment;IIS-ASPNET;IIS-NetFxExtensibility;IIS-ASP;IIS-ISAPIExtensions;IIS-ISAPIFilter;IIS-HealthAndDiagnostics;IIS-HttpLogging;IIS-LoggingLibraries;IIS-RequestMonitor;IIS-HttpTracing;IIS-CustomLogging;IIS-Security;IIS-WindowsAuthentication;IIS-RequestFiltering;IIS-IPSecurity;IIS-Performance;IIS-HttpCompressionStatic;IIS-WebServerManagementTools;IIS-ManagementConsole;IIS-ManagementScriptingTools;IIS-ManagementService;WAS-WindowsActivationService; WAS-ProcessModel;WAS-NetFxEnvironment;WAS-ConfigurationAPI;NetFx3

MOre Information: I am using following code to check if IIS is already installed

<Property Id="IISMAJORVERSION"><RegistrySearch Id="IISInstalledVersion" Root="HKLM" Key="SOFTWARE\Microsoft\InetStp" Type="raw" Name="MajorVersion" /></Property><Condition Message="Error: This application requires IIS 7.0 to be installed. Please install IIS 7.0 and run this installer again.">IISMAJORVERSION</Condition>

On one of the other machine, this condition is true, as there is no IIS installed. But when using msi, there is no error message and log file says: MSI (s) (CC:F8) [15:32:00:761]: Skipping action: InstallIISCA (condition is false)?? How can this be possible.

Also created an alternate CA in C# but its also failing with Windows package Manager error: Operation Failed

[CustomAction]
    public static ActionResult InstallIIS(Session session)        
    {
        try
        {
            Process proc = new Process();
            string cmd = @"C:\Windows\System32\pkgmgr.exe";

            string cmdargument =
                @" start /w pkgmgr /iu:IIS-WebServerRole;IIS-WebServer;IIS-CommonHttpFeatures;
                IIS-StaticContent;IIS-DefaultDocument;IIS-DirectoryBrowsing;IIS-HttpErrors;IIS-HttpRedirect;IIS-ApplicationDevelopment;
                IIS-ASPNET;IIS-NetFxExtensibility;IIS-ASP;IIS-ISAPIExtensions;IIS-ISAPIFilter;IIS-HealthAndDiagnostics;IIS-HttpLogging;
                IIS-LoggingLibraries;IIS-RequestMonitor;IIS-HttpTracing;IIS-CustomLogging;IIS-Security;IIS-WindowsAuthentication;
                IIS-RequestFiltering;IIS-IPSecurity;IIS-Performance;IIS-HttpCompressionStatic;IIS-WebServerManagementTools;
                IIS-ManagementConsole;IIS-ManagementScriptingTools;IIS-ManagementService;WAS-WindowsActivationService;
                WAS-ProcessModel;WAS-NetFxEnvironment;WAS-ConfigurationAPI;NetFx3";

            proc = Process.Start(cmd, cmdargument);
            proc.WaitForExit();
            proc.Close();
        }
        catch (Exception objException)
        {
            // Log the exception
            MessageBox.Show("Error message:" + objException.Message);
        }
        return ActionResult.Success;
    }

Can someone suggest me on how to achieve this? Sincere thanks!

2

There are 2 answers

2
Kim On

I figured it out!!

Posting the solution in case anyone else needs the same :-)

<Property Id="INSTALLIISPROP" Value="C:\Windows\System32\dism.exe"></Property> 
  <CustomAction Id="InstallIISCA" Return="check" Property="INSTALLIISPROP" Execute="deferred" HideTarget="yes"  Impersonate="yes" 
      ExeCommand="/Online /Enable-Feature /FeatureName:IIS-WebServerRole .....(all remaining parameters) />
0
Sonu Chauha On

Do not use "start /w pkgmgr" when initializing "string cmdargument" so your cmdargument will be:

cmdargument = @" /iu:IIS-WebServerRole;IIS-WebServer;IIS-CommonHttpFeatures;
                IIS-StaticContent;IIS-DefaultDocument;IIS-DirectoryBrowsing;IIS-HttpErrors;IIS-HttpRedirect;IIS-ApplicationDevelopment;
                IIS-ASPNET;IIS-NetFxExtensibility;IIS-ASP;IIS-ISAPIExtensions;IIS-ISAPIFilter;IIS-HealthAndDiagnostics;IIS-HttpLogging;
                IIS-LoggingLibraries;IIS-RequestMonitor;IIS-HttpTracing;IIS-CustomLogging;IIS-Security;IIS-WindowsAuthentication;
                IIS-RequestFiltering;IIS-IPSecurity;IIS-Performance;IIS-HttpCompressionStatic;IIS-WebServerManagementTools;
                IIS-ManagementConsole;IIS-ManagementScriptingTools;IIS-ManagementService;WAS-WindowsActivationService;
                WAS-ProcessModel;WAS-NetFxEnvironment;WAS-ConfigurationAPI;NetFx3";