Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Install IIS from C# code

Tags:

c#

iis

Is any way that I can install IIS from C# code?
I need to create a deploy installer for my application but I need that IIS to be installed in the machine so I want to verify if IIS is installed using C# code and install it if it's not.
The installer must work with all versions of IIS.

Thanks in advance.
Paulo

like image 597
Paulo Avatar asked Jul 14 '10 10:07

Paulo


People also ask

Can IIS be installed on D drive?

You don't choose to install IIS on a specific drive. It just goes on the system drive. You can however choose where to place the files for your site. That's part of the "Basic Settings" when you configure your site in IIS, and you're free to place those files wherever you want in the file system.

How do I migrate from C to D in IIS?

In IIS Manager, expand the local computer, expand the Web Sites directory, right-click the Web site you wish to change, and click Stop. Use Windows Explorer, to rename the LocalDrive:\Inetpub\Wwwroot directory to the name of your choice. Alternatively, you can copy the entire \Wwwroot directory tree to a new location.


1 Answers

Here in the method I used: I call the followind command line applications for the different IIS versions.
For IIS 5.1 (Windows XP) and IIS 6 (Windows Server 2003):

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

Content of IIS_on.txt

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

For IIS 7 (Windows Vista) and 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

Here are some links about this subject:
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/

like image 58
Paulo Avatar answered Oct 21 '22 21:10

Paulo