以编程方式启用(安装)IIS
Programmatically enable (install) IIS
有时会有一台没有 IIS 的 PC。它要么被禁用,要么没有安装。在这种情况下,我需要自己启用它 according to those steps。
我正在尝试创建应用程序来检查 IIS 是否已启用(安装),如果没有启用(安装)它。
我尝试在安装前使用 .msi files from here, but it asking me to follow those stpes 安装 IIS。
我尝试使用 Advanced Installer,但显然它安装了 IIS 8.0 Express,但它仍然使 IIS 处于禁用状态。
我需要做什么才能以编程方式启用 IIS?如果我需要运行一个IIS安装文件来完成它也是可以接受的(我没有找到合适的)。
您可以通过命令行安装IIS。以下命令将在 Windows 8 上安装 IIS(您可以将其编辑为 add/remove 某些功能。这只是我过去使用过的命令):
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
在 C# 中,您可以创建一个执行此命令的进程,如下所示:
string command = "the above command";
ProcessStartInfo pStartInfo = new ProcessStartInfo("cmd.exe", "/c " + command);
Process p = new Process();
p.StartInfo = pStartInfo;
p.Start();
您可以从命令行安装 IIS。首先你需要启用 ASP.NET 3.5:
IIS-ASPNET;IIS-NetFxExtensibility;NetFx4Extended-ASPNET45
或 4.5:
IIS-ASPNET45;IIS-NetFxExtensibility45;NetFx4Extended-ASPNET45
之后就可以安装IIS8了,基本上和IIS7一样。检查 IIS7 安装 http://www.iis.net/learn/install/installing-iis-7/installing-iis-from-the-command-line
您用 InstallShield 标记了您的问题,所以我提到更高版本的 InstallShield 支持启用 windows 功能:
Enabling Windows Roles and Features During a Suite/Advanced UI Installation
也就是说,我通常不喜欢这样做,因为您确实会干扰 PC 的配置。我更喜欢检查是否安装了所需的功能,如果没有安装则阻止。
另一个想法是 ASP.NET 5.0 现在支持自托管,就像过去的 WCF 等其他技术一样。简单地放弃对 IIS 的需求并以这种方式解决问题可能是有意义的。
关于您使用高级安装程序的体验。您最终安装了 IIS Express,因为您使用了我们对先决条件的预定义支持。您应该一直在使用对 install Windows Feature Bundles.
的预定义支持
使用此支持,您可以轻松地 select 应启用哪个 OS 功能并设置自定义条件。在我们的 YouTube 频道上,您可以找到 examples/tutorials:
有时会有一台没有 IIS 的 PC。它要么被禁用,要么没有安装。在这种情况下,我需要自己启用它 according to those steps。
我正在尝试创建应用程序来检查 IIS 是否已启用(安装),如果没有启用(安装)它。
我尝试在安装前使用 .msi files from here, but it asking me to follow those stpes 安装 IIS。
我尝试使用 Advanced Installer,但显然它安装了 IIS 8.0 Express,但它仍然使 IIS 处于禁用状态。
我需要做什么才能以编程方式启用 IIS?如果我需要运行一个IIS安装文件来完成它也是可以接受的(我没有找到合适的)。
您可以通过命令行安装IIS。以下命令将在 Windows 8 上安装 IIS(您可以将其编辑为 add/remove 某些功能。这只是我过去使用过的命令):
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
在 C# 中,您可以创建一个执行此命令的进程,如下所示:
string command = "the above command";
ProcessStartInfo pStartInfo = new ProcessStartInfo("cmd.exe", "/c " + command);
Process p = new Process();
p.StartInfo = pStartInfo;
p.Start();
您可以从命令行安装 IIS。首先你需要启用 ASP.NET 3.5:
IIS-ASPNET;IIS-NetFxExtensibility;NetFx4Extended-ASPNET45
或 4.5:
IIS-ASPNET45;IIS-NetFxExtensibility45;NetFx4Extended-ASPNET45
之后就可以安装IIS8了,基本上和IIS7一样。检查 IIS7 安装 http://www.iis.net/learn/install/installing-iis-7/installing-iis-from-the-command-line
您用 InstallShield 标记了您的问题,所以我提到更高版本的 InstallShield 支持启用 windows 功能:
Enabling Windows Roles and Features During a Suite/Advanced UI Installation
也就是说,我通常不喜欢这样做,因为您确实会干扰 PC 的配置。我更喜欢检查是否安装了所需的功能,如果没有安装则阻止。
另一个想法是 ASP.NET 5.0 现在支持自托管,就像过去的 WCF 等其他技术一样。简单地放弃对 IIS 的需求并以这种方式解决问题可能是有意义的。
关于您使用高级安装程序的体验。您最终安装了 IIS Express,因为您使用了我们对先决条件的预定义支持。您应该一直在使用对 install Windows Feature Bundles.
的预定义支持使用此支持,您可以轻松地 select 应启用哪个 OS 功能并设置自定义条件。在我们的 YouTube 频道上,您可以找到 examples/tutorials: