2010-07-14 267 views
6

有什么办法可以从C#代码安装IIS?
我需要为我的应用程序创建一个部署安装程序,但我需要将IIS安装在机器中,所以我想验证IIS是否使用C#代码安装,如果不是,请安装它。
安装程序必须使用所有版本的IIS。从C#代码安装IIS

在此先感谢。
Paulo

+1

从谷歌的结果: http://www.codeproject.com/KB/cs/iisdetection.aspx http://support.microsoft.com /default.aspx?scid=kb;en-us;309506 http://www.appdeploy.com/packages/detail.asp?id=93 – 2010-07-14 10:27:43

+0

看看http://stackoverflow.com/questions/1649180/确实,网络平台的安装程序支持自动化。您可以使用Web平台安装程序来开始安装,但它需要用户交互。 – 2010-07-14 11:49:43

+1

@Jaroslav,如果谷歌的第一个结果是相关的东西不是一个页面上的计算器,那么我们需要解决这个问题! :) – Rob 2010-07-26 22:09:36

回答

8

在这里我使用的方法: 我为不同的IIS版本调用followind命令行应用程序。
对于IIS 5.1(Windows XP中)和IIS 6(在Windows Server 2003):IIS_on.txt

[Components] 
iis_common = ON 
iis_www = ON 
iis_www_vdir_scripts = ON 
iis_inetmgr = ON 
fp_extensions = ON 
iis_ftp = ON 

Sysocmgr.exe /i:sysoc.inf /u:IIS_on.txt 

内容IIS 7(Windows Vista中)和7.5(Windows 7的):

start /w pkgmgr /l:log.etw /iu:IIS-WebServerRole;IIS-WebServer;IIS-CommonHttpFeatures;IIS-StaticContent;IIS-DefaultDocument;IIS-DirectoryBrowsing;IIS-HttpErrors;IIS-HttpRedirect;IIS-ApplicationDevelopment;IIS-ASPNET;IIS-NetFxExtensibility;IIS-ASP;IIS-CGI;IIS-ISAPIExtensions;IIS-ISAPIFilter;IIS-ServerSideIncludes;IIS-HealthAndDiagnostics;IIS-HttpLogging;IIS-LoggingLibraries;IIS-RequestMonitor;IIS-HttpTracing;IIS-CustomLogging;IIS-Security;IIS-BasicAuthentication;IIS-URLAuthorization;IIS-RequestFiltering;IIS-IPSecurity;IIS-Performance;IIS-HttpCompressionStatic;IIS-HttpCompressionDynamic;IIS-WebServerManagementTools;IIS-ManagementConsole;IIS-ManagementScriptingTools;IIS-ManagementService;IIS-IIS6ManagementCompatibility;IIS-Metabase;IIS-WMICompatibility;IIS-LegacyScripts;IIS-LegacySnapIn;WAS-WindowsActivationService;WAS-ProcessModel;WAS-NetFxEnvironment;WAS-ConfigurationAPI 

以下是有关这个问题的一些链接:
http://blogs.msdn.com/b/rakkimk/archive/2007/06/22/how-to-perform-an-unattended-install-uninstall-of-iis-5-0-5-1-6-0.aspx
http://support.microsoft.com/kb/309506
http://technet.microsoft.com/pt-br/library/cc731911(WS.10).aspx
http://learn.iis.net/page.aspx/132/install-iis-7-from-the-command-line/
http://learn.iis.net/page.aspx/479/iis-70-features-and-vista-editions/
http://learn.iis.net/page.aspx/135/discover-installed-components/