Ok, so our customers are tired of having us have an IIS prerequisite in our product installer. They want us to install and configure IIS for them.
So I found this article: Installing IIS 7.0 from the Command Line
I am testing the command line provided in this article in a command prompt. I have verified the command prompt is running as Administrator.
On Windows 2008 R2, it failed with this error: -2146498548
So if at first you don’t succeed, try, try again.
Well, I don’t actually need everything in the script. So I tested this command line:
start /w PkgMgr.exe /iu:IIS-WebServerRole;
This command succeeded. The resulting installed IIS Roles and Services are these.
Note: This output is give by running this command: servermanagercmd.exe -query
[X] Web Server (IIS) [Web-Server]
[X] Web Server [Web-WebServer]
[X] Common HTTP Features [Web-Common-Http]
[X] Static Content [Web-Static-Content]
[X] Default Document [Web-Default-Doc]
[X] Directory Browsing [Web-Dir-Browsing]
[X] HTTP Errors [Web-Http-Errors]
[ ] HTTP Redirection [Web-Http-Redirect]
[ ] WebDAV Publishing [Web-DAV-Publishing]
[ ] Application Development [Web-App-Dev]
[ ] ASP.NET [Web-Asp-Net]
[ ] .NET Extensibility [Web-Net-Ext]
[ ] ASP [Web-ASP]
[ ] CGI [Web-CGI]
[ ] ISAPI Extensions [Web-ISAPI-Ext]
[ ] ISAPI Filters [Web-ISAPI-Filter]
[ ] Server Side Includes [Web-Includes]
[X] Health and Diagnostics [Web-Health]
[X] HTTP Logging [Web-Http-Logging]
[ ] Logging Tools [Web-Log-Libraries]
[X] Request Monitor [Web-Request-Monitor]
[ ] Tracing [Web-Http-Tracing]
[ ] Custom Logging [Web-Custom-Logging]
[ ] ODBC Logging [Web-ODBC-Logging]
[X] Security [Web-Security]
[ ] Basic Authentication [Web-Basic-Auth]
[ ] Windows Authentication [Web-Windows-Auth]
[ ] Digest Authentication [Web-Digest-Auth]
[ ] Client Certificate Mapping Authentication [Web-Client-Auth]
[ ] IIS Client Certificate Mapping Authentication [Web-Cert-Auth]
[ ] URL Authorization [Web-Url-Auth]
[X] Request Filtering [Web-Filtering]
[ ] IP and Domain Restrictions [Web-IP-Security]
[X] Performance [Web-Performance]
[X] Static Content Compression [Web-Stat-Compression]
[ ] Dynamic Content Compression [Web-Dyn-Compression]
[X] Management Tools [Web-Mgmt-Tools]
[X] IIS Management Console [Web-Mgmt-Console]
[ ] IIS Management Scripts and Tools [Web-Scripting-Tools]
[ ] Management Service [Web-Mgmt-Service]
[ ] IIS 6 Management Compatibility [Web-Mgmt-Compat]
[ ] IIS 6 Metabase Compatibility [Web-Metabase]
[ ] IIS 6 WMI Compatibility [Web-WMI]
[ ] IIS 6 Scripting Tools [Web-Lgcy-Scripting]
[ ] IIS 6 Management Console [Web-Lgcy-Mgmt-Console]
[ ] FTP Server [Web-Ftp-Server]
[ ] FTP Service [Web-Ftp-Service]
[ ] FTP Extensibility [Web-Ftp-Ext]
[ ] IIS Hostable Web Core [Web-WHC]
This is almost enough but I also need these more than the default. I also need the ones below that I have put an “I” in.
[X] Web Server (IIS) [Web-Server]
[X] Web Server [Web-WebServer]
[X] Common HTTP Features [Web-Common-Http]
[X] Static Content [Web-Static-Content]
[X] Default Document [Web-Default-Doc]
[X] Directory Browsing [Web-Dir-Browsing]
[X] HTTP Errors [Web-Http-Errors]
[ ] HTTP Redirection [Web-Http-Redirect]
[ ] WebDAV Publishing [Web-DAV-Publishing]
[ ] Application Development [Web-App-Dev]
[ ] ASP.NET [Web-Asp-Net]
[ ] .NET Extensibility [Web-Net-Ext]
[I] ASP [Web-ASP]
[I] CGI [Web-CGI]
[I] ISAPI Extensions [Web-ISAPI-Ext]
[ ] ISAPI Filters [Web-ISAPI-Filter]
[I] Server Side Includes [Web-Includes]
[X] Health and Diagnostics [Web-Health]
[X] HTTP Logging [Web-Http-Logging]
[ ] Logging Tools [Web-Log-Libraries]
[X] Request Monitor [Web-Request-Monitor]
[ ] Tracing [Web-Http-Tracing]
[ ] Custom Logging [Web-Custom-Logging]
[ ] ODBC Logging [Web-ODBC-Logging]
[X] Security [Web-Security]
[ ] Basic Authentication [Web-Basic-Auth]
[I] Windows Authentication [Web-Windows-Auth]
[ ] Digest Authentication [Web-Digest-Auth]
[ ] Client Certificate Mapping Authentication [Web-Client-Auth]
[ ] IIS Client Certificate Mapping Authentication [Web-Cert-Auth]
[ ] URL Authorization [Web-Url-Auth]
[X] Request Filtering [Web-Filtering]
[ ] IP and Domain Restrictions [Web-IP-Security]
[X] Performance [Web-Performance]
[X] Static Content Compression [Web-Stat-Compression]
[ ] Dynamic Content Compression [Web-Dyn-Compression]
[X] Management Tools [Web-Mgmt-Tools]
[X] IIS Management Console [Web-Mgmt-Console]
[ ] IIS Management Scripts and Tools [Web-Scripting-Tools]
[ ] Management Service [Web-Mgmt-Service]
[I] IIS 6 Management Compatibility [Web-Mgmt-Compat]
[I] IIS 6 Metabase Compatibility [Web-Metabase]
[ ] IIS 6 WMI Compatibility [Web-WMI]
[ ] IIS 6 Scripting Tools [Web-Lgcy-Scripting]
[ ] IIS 6 Management Console [Web-Lgcy-Mgmt-Console]
[ ] FTP Server [Web-Ftp-Server]
[ ] FTP Service [Web-Ftp-Service]
[ ] FTP Extensibility [Web-Ftp-Ext]
[ ] IIS Hostable Web Core [Web-WHC]
So the article was somewhat correct. Turns out this command line works:
start /w PkgMgr.exe /iu:IIS-WebServerRole;IIS-CommonHttpFeatures;IIS-StaticContent;IIS-DirectoryBrowsing;IIS-HttpRedirect;IIS-ApplicationDevelopment;IIS-ASP;IIS-CGI;IIS-ISAPIExtensions;IIS-ServerSideIncludes;IIS-Security;IIS-WindowsAuthentication;IIS-WebServerManagementTools;IIS-ManagementConsole;IIS-IIS6ManagementCompatibility;IIS-Metabase
And this command line satisfies all my requirements.