编程方式启用(安装)IIS [英] Programmatically enable (install) IIS

查看:585
本文介绍了编程方式启用(安装)IIS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有时有不具有的IIS的PC。它要么禁用或任它没有安装。在这种情况下,我需要启用它自己根据这些步骤

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.

我想创建应用程序,如果启用IIS(安装),将检查,如果没有它将使(安装)它。

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

我尝试使用从这里的.msi文件安装IIS < /一>,但要我按照那些stpes安装前的。

我试图用高级安装但显然它在安装IIS 8.0防爆preSS但仍一直在IIS中禁用。

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

输入图像的描述在这里

我需要做的编程方式启用IIS?这也是可以接受的,如果我需要运行IIS的安装文件,以它做(我没有找到合适的人)。

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).

推荐答案

您可以通过命令行安装IIS。以下命令将在Windows 8上安装IIS(你可以编辑该添加/删除某些功能,这只是我已经在过去使用的命令。):

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:

启动/ 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-HttpCom$p$pssionStatic;IIS-WebServerManagementTools;IIS-ManagementConsole;WAS-WindowsActivationService;WAS-ProcessModel;WAS-NetFxEnvironment;WAS-ConfigurationAPI

DISM:

START / WAIT DISM /在线/启用,功能/ 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-HttpCom pressionDynamic / FeatureName:IIS-HttpCom pressionStatic / FeatureName:IIS-HttpErrors / FeatureName:IIS-HttpLogging / FeatureName: IIS-的Htt predirect / FeatureName:IIS-HttpTracing / FeatureName:IIS-IIS6ManagementCompatibility / FeatureName:IIS-IISCertificateMappingAuthentication / FeatureName:IIS-IP安全/ 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-元数据库/ FeatureName:IIS-NetFxExtensibility / FeatureName:IIS-ODBCLogging / FeatureName: IIS的性能/ FeatureName:IIS-的requestFiltering / FeatureName:IIS-RequestMonitor / FeatureName:IIS-安全/ FeatureName:IIS-ServerSideIncludes / FeatureName:IIS-StaticContent / FeatureName:IIS-URLAuthorization / FeatureName:IIS的WebDAV的/ FeatureName:IIS- Web服务器/ FeatureName:IIS-WebServerManagementTools / FeatureName:IIS-WebServerRole / FeatureName:IIS-WindowsAuthentication / FeatureName:IIS-WMICompatibility / FeatureName:WAS-ConfigurationAPI / FeatureName:WAS-NetFxEnvironment / FeatureName:WAS-中processModel / FeatureName:WAS-WindowsActivati​​onService

在C#中,你可以创建一个执行该命令,像这样一个过程:

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();

这篇关于编程方式启用(安装)IIS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆