Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Programmatically enable (install) IIS

Sometimes there is a PC that doesn't have IIS. Either it disabled or either it not installed. In this case I need to enable it myself according to those steps.

I'm trying to create application that will check if IIS is enabled (installed), and if not it will enable (install) it.

I tried to install IIS using .msi files from here, but it asking me to follow those stpes before the installation.

I tried to use Advanced Installer but apparently it installing the IIS 8.0 Express but still it keeps the IIS disabled.

enter image description here

What I need to do to enable IIS programmatically? It is also acceptable if I'll need to run an IIS installation file to make it done (I didn't find the right one).

like image 864
altgov3en Avatar asked Aug 19 '15 13:08

altgov3en


People also ask

How do I manually install IIS?

On the Start page, click the Control Panel tile. In Control Panel, click Programs, and then click Turn Windows features on or off. In the Windows Features dialog box, click Internet Information Services to install the default features.


2 Answers

You can install IIS via the command line. The following command will install IIS on Windows 8 (you can edit this to add/remove certain features. It's just a command I've used in the past):

PkgMgr:

start /w pkgmgr /iu:IIS-WebServerRole;IIS-WebServer;IIS-CommonHttpFeatures;IIS-StaticContent;IIS-DefaultDocument;IIS-DirectoryBrowsing;IIS-HttpErrors;IIS-ApplicationDevelopment;IIS-ISAPIExtensions;IIS-ISAPIFilter;IIS-NetFxExtensibility45;IIS-ASPNET45;IIS-NetFxExtensibility;IIS-ASPNET;IIS-HealthAndDiagnostics;IIS-HttpLogging;IIS-RequestMonitor;IIS-Security;IIS-RequestFiltering;IIS-HttpCompressionStatic;IIS-WebServerManagementTools;IIS-ManagementConsole;WAS-WindowsActivationService;WAS-ProcessModel;WAS-NetFxEnvironment;WAS-ConfigurationAPI

DISM:

START /WAIT DISM /Online /Enable-Feature /FeatureName:IIS-ApplicationDevelopment /FeatureName:IIS-ASP /FeatureName:IIS-ASPNET /FeatureName:IIS-BasicAuthentication /FeatureName:IIS-CGI /FeatureName:IIS-ClientCertificateMappingAuthentication /FeatureName:IIS-CommonHttpFeatures /FeatureName:IIS-CustomLogging /FeatureName:IIS-DefaultDocument /FeatureName:IIS-DigestAuthentication /FeatureName:IIS-DirectoryBrowsing /FeatureName:IIS-FTPExtensibility /FeatureName:IIS-FTPServer /FeatureName:IIS-FTPSvc /FeatureName:IIS-HealthAndDiagnostics /FeatureName:IIS-HostableWebCore /FeatureName:IIS-HttpCompressionDynamic /FeatureName:IIS-HttpCompressionStatic /FeatureName:IIS-HttpErrors /FeatureName:IIS-HttpLogging /FeatureName:IIS-HttpRedirect /FeatureName:IIS-HttpTracing /FeatureName:IIS-IIS6ManagementCompatibility /FeatureName:IIS-IISCertificateMappingAuthentication /FeatureName:IIS-IPSecurity /FeatureName:IIS-ISAPIExtensions /FeatureName:IIS-ISAPIFilter /FeatureName:IIS-LegacyScripts /FeatureName:IIS-LegacySnapIn /FeatureName:IIS-LoggingLibraries /FeatureName:IIS-ManagementConsole /FeatureName:IIS-ManagementScriptingTools /FeatureName:IIS-ManagementService /FeatureName:IIS-Metabase /FeatureName:IIS-NetFxExtensibility /FeatureName:IIS-ODBCLogging /FeatureName:IIS-Performance /FeatureName:IIS-RequestFiltering /FeatureName:IIS-RequestMonitor /FeatureName:IIS-Security /FeatureName:IIS-ServerSideIncludes /FeatureName:IIS-StaticContent /FeatureName:IIS-URLAuthorization /FeatureName:IIS-WebDAV /FeatureName:IIS-WebServer /FeatureName:IIS-WebServerManagementTools /FeatureName:IIS-WebServerRole /FeatureName:IIS-WindowsAuthentication /FeatureName:IIS-WMICompatibility /FeatureName:WAS-ConfigurationAPI /FeatureName:WAS-NetFxEnvironment /FeatureName:WAS-ProcessModel /FeatureName:WAS-WindowsActivationService

In C#, you can create a Process that executes this command like so:

string command = "the above command";
ProcessStartInfo pStartInfo = new ProcessStartInfo("cmd.exe", "/c " + command);
Process p = new Process();
p.StartInfo = pStartInfo;
p.Start();
like image 50
Oliver Nicholls Avatar answered Oct 06 '22 01:10

Oliver Nicholls


You tag your question with InstallShield so I mention that later versions of InstallShield have support for enabling windows features:

Enabling Windows Roles and Features During a Suite/Advanced UI Installation

That said, I don't typically like to do this because you are really be intrusive with the configuration of the PC. I prefer to author a check that the required features are installed and block if they aren't.

Another thought is that ASP.NET 5.0 now supports self hosting as have other technologies such as WCF in the past. It might make sense to simply ditch the need for IIS and kill the problem that way.

like image 21
Christopher Painter Avatar answered Oct 05 '22 23:10

Christopher Painter