I worked for a customer who wanted to have a script which will install IIS on some 200 machines in his network. We already have a KB http://support.microsoft.com/kb/309506 which talks about the unattended installation of IIS 6.0.
In this post, I will just break the same KB and place the individual files to do the same. After the installation of the operating system, we can use the command-line tool for adding and removing Windows components, Sysocmgr.exe for installing or uninstalling additional Windows components. Let's come to our requirement. For the Sysocmgr.exe you need to give an answer file which has the list of components that needs to be installed. Below is the sample answer file which will have the default installation of IIS components + FTP:
iis_common = ON
iis_www = ON
iis_www_vdir_scripts = ON
iis_inetmgr = ON
fp_extensions = ON
iis_ftp = ON
Save the above text in a file named IIS_on.txt in your local hard disk. Now, we need to write a batch file which we will make to execute during the system start up. Place the below test in a file called install_iis.bat and save it.
Sysocmgr.exe /i:sysoc.inf /u:IIS_on.txt
So, we have our IIS installation files and also the batch file ready. Now, how to modify the script or the answer file to uninstall IIS components? Simple - there is no change in the batch file for this, only change is to change all ON to OFF - uninstallation answer file.
Refer the KB for the other optional components of IIS.