I'm not sure about this, but if the DISM API can do this, it might be somewhat easier. DismEnableFeature(), for example.
Phil Wilson On Wed, Dec 11, 2013 at 6:59 AM, John Walter <jo...@twofold-software.com>wrote: > Thanks Steven yes I have similar also by checking the registry I build a > list of the missing features so in theory if all the needed features are > active I should not need to run DISM. > > As I said my main issue is with the seemingly random nature of what happens > when DISM is run on the one PC starting from a fixed point just after > installing Windows I have seen it work with no error, error out with the > error 0x800f0906 and require the PC to be restarted before IIS is active. I > was hoping that there might be a more reliable way than using DISM of > activating the IIS. > > > > > On 11 December 2013 14:33, Steven Ogilvie <steven.ogil...@titus.com> > wrote: > > > One problem is that between the different versions of Windows the DISM > > command line parameters have changed... > > I have created a custom action that checks what version of Windows I am > > running and then sets the command line parameters up accordingly... > > Btw WriteErrorLogInstall is a custom logging function replace it with the > > session logging... > > > > /// <summary> > > /// The check web server roles. > > /// </summary> > > /// <param name="session"> > > /// The session. > > /// </param> > > /// <returns> > > /// The<see cref="ActionResult"/>. > > /// </returns> > > /// <exception cref="ArgumentNullException"> > > /// throw new ArgumentNullException("session"); > > /// </exception> > > [CustomAction] > > public static ActionResult CheckWebServerRoles(Session session) > > { > > var productName = string.Empty; > > try > > { > > if (session == null) > > { > > throw new ArgumentNullException("session"); > > } > > > > var tempString = GetSessionProperty(session, > > "CustomActionData", false); > > var parts = tempString.Split(new[] { '|' }); > > productName = parts[0]; > > > > var platformVersion = > Environment.OSVersion.VersionString; > > > > var cmdLineParameters = string.Empty; > > if (platformVersion.Contains("6.1.760") && > > !Os.IsWindowsServer()) > > { > > // Windows 7 > > cmdLineParameters = "/Online /NoRestart > > /Enable-Feature /featurename:IIS-WebServerRole > > /featurename:IIS-CommonHttpFeatures /featurename:IIS-StaticContent > > /featurename:IIS-WebServerRole /featurename:IIS-ApplicationDevelopment > > /featurename:IIS-ISAPIFilter /featurename:IIS-ISAPIExtensions > > /featurename:IIS-NetFxExtensibility /featurename:IIS-ASPNET > > /featurename:IIS-WebServerRole /featurename:IIS-Security > > /featurename:IIS-RequestFiltering /featurename:IIS-WindowsAuthentication > > /featurename:WAS-ProcessModel /featurename:WAS-WindowsActivationService > > /featurename:WAS-NetFxEnvironment /featurename:WAS-ConfigurationAPI > > /featurename:NetFx3 /featurename:WCF-HTTP-Activation"; > > } > > else if (platformVersion.Contains("6.1.760") && > > Os.IsWindowsServer()) > > { > > // Windows Server 2008 R2 > > cmdLineParameters = "/Online /NoRestart > > /Enable-Feature /featurename:IIS-WebServerRole > > /featurename:IIS-CommonHttpFeatures /featurename:IIS-StaticContent > > /featurename:IIS-WebServerRole /featurename:IIS-ApplicationDevelopment > > /featurename:IIS-ISAPIFilter /featurename:IIS-ISAPIExtensions > > /featurename:IIS-NetFxExtensibility /featurename:IIS-ASPNET > > /featurename:IIS-WebServerRole /featurename:IIS-Security > > /featurename:IIS-RequestFiltering /featurename:IIS-WindowsAuthentication > > /featurename:NetFx3 /featurename:WCF-HTTP-Activation"; > > } > > else if (platformVersion.Contains("6.2.920") && > > !Os.IsWindowsServer()) > > { > > // Windows 8 > > cmdLineParameters = "/Online /NoRestart > > /Enable-Feature /featurename:IIS-WebServerRole > > /featurename:IIS-CommonHttpFeatures /featurename:IIS-StaticContent > > /featurename:IIS-ApplicationDevelopment /featurename:IIS-ISAPIFilter > > /featurename:IIS-ISAPIExtensions /featurename:IIS-NetFxExtensibility45 > > /featurename:IIS-ASPNET45 /featurename:IIS-Security > > /featurename:IIS-RequestFiltering /featurename:IIS-WindowsAuthentication > > /featurename:NetFx4-AdvSrvs /featurename:NetFx4Extended-ASPNET45 > > /featurename:WCF-Services45 /featurename:WCF-HTTP-Activation45 /All"; > > } > > else if (platformVersion.Contains("6.2.920") && > > Os.IsWindowsServer()) > > { > > // Windows Server 2012 > > cmdLineParameters = "/Online /NoRestart > > /Enable-Feature /featurename:IIS-WebServerRole > > /featurename:IIS-CommonHttpFeatures /featurename:IIS-StaticContent > > /featurename:IIS-ApplicationDevelopment /featurename:IIS-ISAPIFilter > > /featurename:IIS-ISAPIExtensions /featurename:IIS-NetFxExtensibility45 > > /featurename:IIS-ASPNET45 /featurename:IIS-Security > > /featurename:IIS-RequestFiltering /featurename:IIS-WindowsAuthentication > > /featurename:NetFx4 /featurename:NetFx4Extended-ASPNET45 > > /featurename:WCF-Services45 /featurename:WCF-HTTP-Activation45 /All"; > > } > > > > var system32Directory = > > > Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows), > > "system32"); > > if (Environment.Is64BitOperatingSystem && > > !Environment.Is64BitProcess) > > { > > // For 32-bit processes on 64-bit systems, > > %windir%\system32 folder > > // can only be accessed by specifying > > %windir%\sysnative folder. > > system32Directory = > > > Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows), > > "sysnative"); > > } > > > > // Windows 7 / 8 / 2008R2 / 2012 > > var cmdLineExe = Path.Combine(system32Directory, > > "dism.exe"); > > > > // Install Web Server features if missing > > var runDismInfo = new ProcessStartInfo > > { > > UseShellExecute = true, > > Arguments = cmdLineParameters, > > FileName = cmdLineExe, > > WindowStyle = ProcessWindowStyle.Hidden, > > CreateNoWindow = true > > }; > > > > // Run the external process & wait for it to finish > > using (var runDismProc = Process.Start(runDismInfo)) > > { > > runDismProc.WaitForExit(); > > } > > } > > catch (Exception ex) > > { > > WriteErrorLogInstall(session, "CheckWebServerRoles > failed: > > ", ex, true); > > if (session != null) > > { > > session.Message( > > InstallMessage.User + (int)MessageBoxIcon.Error + > > (int)MessageBoxButtons.OK, > > new Record { FormatString = productName + " > failed > > to install specific Web Server features\nException: " + ex.Message }); > > } > > > > return ActionResult.Failure; > > } > > > > WriteSuccessLogInstall(session, "CheckWebServerRoles > succeeded > > to install specific Web Server features...", true); > > return ActionResult.Success; > > } > > > > > > /// <summary> > > /// The OS. > > /// </summary> > > private class Os > > { > > /// <summary> > > /// The OS ANYSERVER. > > /// </summary> > > [SuppressMessage("StyleCop.CSharp.NamingRules", > > "SA1310:FieldNamesMustNotContainUnderscore", Justification = "Reviewed. > > Suppression is OK here.")] > > // ReSharper disable InconsistentNaming > > private const int OS_ANYSERVER = 29; > > // ReSharper restore InconsistentNaming > > > > /// <summary> > > /// Prevents a default instance of the <see cref="Os"/> class > > from being created. > > /// </summary> > > private Os() > > { > > } > > > > /// <summary> > > /// The is windows server. > > /// </summary> > > /// <returns> > > /// The <see cref="bool"/>. > > /// </returns> > > public static bool IsWindowsServer() > > { > > return IsOS(OS_ANYSERVER); > > } > > > > [DllImport("shlwapi.dll", SetLastError = true, EntryPoint = > > "#437")] > > private static extern bool IsOS(int os); > > } > > > > -----Original Message----- > > From: John Walter [mailto:jo...@twofold-software.com] > > Sent: December-11-13 5:41 AM > > To: WiX-users@lists.sourceforge.net > > Subject: [WiX-users] Help activating IIS using the DISM command > > > > Hi, > > > > I am fairly new to the WiX installer but have been able to create an > > install package that creates our website and installs all needed > components > > some being installed from other installers run from my bootstrapper. > > > > The one element I am having difficulties with is enabling IIS. We need to > > have the ASPNET45 features enabled for our web page to operate so even if > > the IIS is enabled on the destination PC I need to check the features > that > > are enabled. I can do this via the registry as each feature has an entry > nd > > so can build a DISM command line that only enabled the missing features. > > > > The problems I am having seem to come from inconsistencies with how the > > DISM command run. Sometimes there are no errors and IIS is up and > running, > > sometimes I get error 0x800f0906 (this is concerning the source of the > > files needed for the features being enabled) and sometimes the IIS is > > installed but will only be running once the PC has been re-booted. The PC > > in all cases was a clean freshly installed version of Windows 8 (32-Bit) > > run as a virtual PC and reset after each attempt but using a snapshot so > I > > am reasonably confident that the PC in all cases was the same. > > > > Can anyone give me a clue as to where I can go from here as it seems the > > only way for me to get round this reliably would be to give detailed > > instructions as to how to enable IIS and what settings are required and > get > > the user to activate manually and only check that the required features > are > > turned on before installing the web site. > > > > > > Example of the DISM command line > > > > DISM /online /enable-feature /featurename:NetFx3 > > /featurename:NetFx4-AdvSrvs /featurename:NetFx4Extended-ASPNET45 > > /featurename:IIS-NetFxExtensibility45 /featurename:IIS-ASPNET45 /All > > > > -- > > > > *John Walter* > > > > > ------------------------------------------------------------------------------ > > Rapidly troubleshoot problems before they affect your business. Most IT > > organizations don't have a clear picture of how application performance > > affects their revenue. With AppDynamics, you get 100% visibility into > your > > Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics > > Pro! > > > http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk > > _______________________________________________ > > WiX-users mailing list > > WiX-users@lists.sourceforge.net > > https://lists.sourceforge.net/lists/listinfo/wix-users > > > > > > > ------------------------------------------------------------------------------ > > Rapidly troubleshoot problems before they affect your business. Most IT > > organizations don't have a clear picture of how application performance > > affects their revenue. With AppDynamics, you get 100% visibility into > your > > Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics > > Pro! > > > http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk > > _______________________________________________ > > WiX-users mailing list > > WiX-users@lists.sourceforge.net > > https://lists.sourceforge.net/lists/listinfo/wix-users > > > > > > -- > > *John Walter* > Two Fold Software Ltd - Defining the Next Generation of LIMS > Dodwell House, Chilton Business Centre,Chilton, Aylesbury,Bucks, HP18 9LS, > UK > > Phone: +44 1844 208598 > Fax: +44 1844 208869 > <http://www.twofold-software.com/> > > ------------------------------------------------------------------------------ > Rapidly troubleshoot problems before they affect your business. Most IT > organizations don't have a clear picture of how application performance > affects their revenue. With AppDynamics, you get 100% visibility into your > Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics > Pro! > http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk > _______________________________________________ > WiX-users mailing list > WiX-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/wix-users > ------------------------------------------------------------------------------ Rapidly troubleshoot problems before they affect your business. Most IT organizations don't have a clear picture of how application performance affects their revenue. With AppDynamics, you get 100% visibility into your Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro! http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk _______________________________________________ WiX-users mailing list WiX-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wix-users