Mehul Vaghela
Mehul Vaghela

Reputation: 478

Enable Windows Feature\Role through Installshield

Our application supported for OS 'Windows server 2012 R2'. We have an application in which we need to have 'Application Initialization' feature to be enabled. We have used Installshield 2014 for making the installer of our application. I have found the implementation of checking the status of any windows feature. I have tried the following code which had given me the list of installed features:

ManagementClass objMC = new ManagementClass("Win32_ServerFeature");
ManagementObjectCollection objMOC = objMC.GetInstances();
string featureName = string.Empty;
var AppInitFeature = (from ManagementObject objectFeature in objMOC
                      where objectFeature.Properties["Name"].Value.ToString() == "Application Initialization"
                      select objectFeature).First();

Here my question is: Is there any built-in capability in installshield to enable the windows feature? OR we need to write any custom action for that. If we need to write a custom action, then how to enable the windows feature through c# code.

Can anyone help me on this.

Thanks in anticipation.

Upvotes: 4

Views: 1379

Answers (1)

Norbert
Norbert

Reputation: 41

As far as i know, the installation of windows roles & features is only available for InstallShield AdvancedUI and Suite projects.

Instead you can create your own setup prerequisite by identifying the feature installation state in the registry and manually enabling the required feature using a batch script.

For example, we did the same for our MSMQ prerequisite: The according registry is HKLM\SOFTWARE\Microsoft\MSMQ\Setup and the entry to check for is msmq_CoreInstalled == 1

The batch file contains the call

%SystemRoot%\sysnative\dism /online /Enable-Feature /FeatureName:MSMQ-Server /all

and some eye candy.

This solution currently works for all windows systems tested so far (which is afaik Windows 7/8/8.1 and Server 2008R2/2012.

Upvotes: 3

Related Questions