Recipe 12.1. Installing IISProblemYou want to install IIS on a Windows Server 2003 computer. Solution
Using a graphical
|
|
The following command
> sysocmgr /i:sysoc.inf /u: <PathToAnswerFile>
For example, if your answer file is named iis_install.txt , is located in the root directory of C : drive, and contains the following entries:
[Components] iis_common = ON iis_doc = ON iis_www = ON iis_inetmgr = ON [InternetServer] SvcManualStart = www PathWWWRoot = C:\webstuff
Then you can install IIS using this command:
> sysocmgr /i:sysoc.inf /u:C:\iis_install.txt
Unfortunately, there are no scripting interfaces for installing IIS. However, you can run the sysocmgr command from the previous section directly within a batch script ( .bat extension) or using the WScript.Shell Run method within VBScript.
' This code simulates the same steps from the command-line solution.
' First, an answer file is created containing the parameters to install
' IIS. Then the sysocmgr command is invoked to perform the installation.
strFile = "c:\iis_install.txt"
constForWriting = 2
set objFSO = CreateObject("Scripting.FileSystemObject")
set objFile = objFSO.OpenTextFile(strFile, constForWriting, True)
objFile.WriteLine("[Components]")
objFile.WriteLine("iis_common = ON")
objFile.WriteLine("iis_doc = ON")
objFile.WriteLine("iis_www = ON")
objFile.WriteLine("iis_inetmgr = ON")
objFile.WriteLine("")
objFile.WriteLine("[InternetServer]")
objFile.WriteLine("SvcManualStart = www")
objFile.WriteLine("PathWWWRoot = C:\webstuff")
objFile.Close
set objWshShell = WScript.CreateObject("WScript.Shell")
intRC = objWshShell.Run("sysocmgr /i:%windir%\inf\sysoc.inf /u:" & _
strFile, 0, TRUE)
if intRC <> 0 then
WScript.Echo "Error returned from sysocmgr command: " & intRC
else
WScript.Echo "IIS installed"
end if
Table 12-2 describes some of the IIS components that you can install by adding entries to the [Components] section of your answer file.
|
Entry |
Description |
|---|---|
|
iis_asp |
Active Server Pages component |
|
iis_common |
Common files needed by other IIS components |
|
iis_doc |
IIS documentation |
|
iis_ftp |
FTP service |
|
iis_inetmgr |
Internet Services Manager snap-in for the MMC |
|
iis_www |
WWW service |
|
fp_extensions |
FrontPage Server Extensions |
|
aspnet |
ASP.NET component |
For additional IIS components you can install, see the Ref.chm help file in the \Support\Tools\Deploy.cab folder on your Windows Server 2003 product CD.
Table 12-3 contains some of the entries you can include in the [InternetServer] section of your answer file.
|
Entry |
Description |
Values |
|---|---|---|
|
PathWWWRoot |
Location of home directory for Default Web Site |
Specify absolute path to directory (enclose in quotes if
|
|
PathFTPRoot |
Location of home directory for Default FTP Site |
Specify absolute path to directory (enclose in quotes if path includes spaces) |
|
SvcManualStart |
WWW and/or FTP services are
|
WWW FTP WWW,FTP |
Note that the entries in the [InternetServer] section require corresponding entries in the [Components] section. For example, if you include an entry for PathWWWRoot in the [InternetServer] section, you must include iis_common , iis_inetmgr , and iis_www in the [Components] section as well. For more information on the entries in these two sections, see the Ref.chm help file.
|
MS KB 323438 (HOW TO: Use Setup Manager to Create an Answer File in Windows Server 2003), MS KB 309506 (How To Perform an Unattended Installation of IIS 6.0), and MS KB 222444 (How to Add or Remove Windows Components with Sysocmgr.exe)