This has come up a couple of times recently so here is my solution.

Create a stub application to run ocsetup e.g.:

namespace OcsRunner
{
    using System;
    using System.Diagnostics;

    public class Program
    {
        public static int Main(string[] args)
        {
            var startInfo = new ProcessStartInfo();

            startInfo.FileName = "ocsetup.exe";
            startInfo.Arguments = String.Join(" ", args) + " /norestart /quiet";
            startInfo.WindowStyle = ProcessWindowStyle.Hidden;
            startInfo.UseShellExecute = false;

            var p = new Process();
            p.StartInfo = startInfo;
            p.Start();
            p.WaitForExit();

            return p.ExitCode;
        }
    }
}

Call this from your bundle like this:

<?define Win2k8ServerR2 = (VersionNT = v6.1 AND NOT (NTProductType = 1)) ?>

  <Fragment>
    <util:RegistrySearch Root="HKLM" Key="SOFTWARE\Microsoft\Net Framework 
Setup\NDP\v3.5" Value="Version" Variable="Netfx35Version" />
      <!-- Use Ocsetup on Windows 8 or Windows Server 2008 R2 -->
      <ExePackage Id="NetFx35OcsSetup"
        DisplayName=".NET Framework 3.5"
        Cache="no"
        Compressed="yes"
        PerMachine="yes"
        Permanent="yes"
        Vital="yes"
        Name="Redist\OcsRunner.exe"
        SourceFile="Packages\OcsRunner.exe"
        InstallCommand="NetFx3"
        DetectCondition="Netfx35Version AND (Netfx35Version &gt;= v3.5.30729.1)"
        InstallCondition="(VersionNT &gt;= v6.2) OR $(var.Win2k8ServerR2)">
        <ExitCode Value ="3010" Behavior="forceReboot" />
      </ExePackage>
  </Fragment>

This example installs .NET 3.5 on Windows Server 2008 R2 and Windows 8 but you 
can replace the InstallCommand and DetectCondition to install other features.

Neil

Neil Sleightholm
X2 Systems Limited
n...@x2systems.com<mailto:n...@x2systems.com>

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users

Reply via email to