As part of an installation process I need to enable the Application Server role. I need to do this to get the distributed transaction features required by an application. I am able to do this easily on a Windows 2012 Server by executing dism.exe from a C# application. Here is the command that is executed.
dism /Online /Enable-Feature /FeatureName:Application-Server /FeatureName:AS-NET-Framework /FeatureName:AS-Ent-Services /FeatureName:AS-Dist-Transaction /FeatureName:AS-Incoming-Trans /FeatureName:AS-Outgoing-Trans
But when I try to do this on a Windows 2008 R2 Server or Windows 7 it fails indicating that DISM does not recognize these features. If I run the command on these machines to list the features (Get-Features) they indeed are not available. Even if I manually enable the Application Server role using the Role Manager and list the features available in DISM they are not listed or anything under a different name that would represent the Application Server Role.
How can I programmatically enable the Application Server Role on a Windows 2008 R2 Server and Windows 7 using C#? The solution does not have to use DISM. I am looking for any options.