Many people believe that it is not possible to relocate the IIS file system hive located at C:\InetPub. Well, this is not true. As a matter of fact, it is very easy to specify the location of the InetPub folder to any drive and path that you want. This does have to be performed when you install Internet Information Services (IIS) to the machine. If IIS is already installed, you will have to remove it.
I personally feel that the system partition should be reserved for the operating system and any program executables. All data files should be located on another partition. This will make recovery and disaster planning much easier. I have even made relocating IIS extremely easy by creating a command file that will install IIS into the location you want using a single command line statement. So, if you want, you can easily relocate C:\InetPub\wwwroot -> D:\InetPub\wwwroot – I like D:\Webs myself.
Basically, what you would have to do is create a setup answer file that specifies the components to activate and the locations of the file hives. Once you have created this file, you install IIS using the sysocmgr.exe setup application and reference the answer file that you have created. I have created a command file that will do this for you. All you have to do is run the command file, and as parameters provide the locations for the wwwroot and ftproot paths. This will fire the setup application, install and configure IIS in the location you want. Just make sure that you have access to the Operating System installation files either through a local path, network share, or CD.
To create this command file, open Notepad and paste the text from the area below. Save the file with the name iisreloc.cmd.
REM 1st Parameter - Location to WWWroot ex. D:\Inetpub\Ftproot
REM 2nd Parameter - Location to FTProot ex. D:\Inetpub\Wwwroot
if "%1" == "" goto USAGE
if "%2" == "" goto USAGE
echo [Components] > %TEMP%\iisreloc.tmp
echo iis_common=on ;IIS Common Services >> %TEMP%\iisreloc.tmp
echo iisdbg=on ;MS Script Debugger >> %TEMP%\iisreloc.tmp
echo iis_doc=off ;IIS Documentation >> %TEMP%\iisreloc.tmp
echo iis_ftp=off ;IIS FTP Service >> %TEMP%\iisreloc.tmp
echo iis_htmla=off ;IIS HTML Administration Files >> %TEMP%\iisreloc.tmp
echo iis_inetmgr=on ;IIS MMC Snap-in >> %TEMP%\iisreloc.tmp
echo iis_nntp=off ;IIS NNTP Service >> %TEMP%\iisreloc.tmp
echo iis_nntp_docs=off ;IIS NNTP Documentation >> %TEMP%\iisreloc.tmp
echo iis_pwmgr=off ;Personal Web Manager Application >> %TEMP%\iisreloc.tmp
echo iis_smtp=off ;IIS SMTP Service >> %TEMP%\iisreloc.tmp
echo iis_smtp_docs=off ;IIS SMTP Documentation >> %TEMP%\iisreloc.tmp
echo iis_www=on ;IIS WWW Service >> %TEMP%\iisreloc.tmp
echo Mts_core = On ;Microsoft Transaction Server core components\ >> %TEMP%\iisreloc.tmp
echo Indexsrv_system = off ;Index Service >> %TEMP%\iisreloc.tmp
echo fp_extensions=off ;Frontpage Server Extensions - found this and the other >> %TEMP%\iisreloc.tmp
echo [InternetServer] >> %TEMP%\iisreloc.tmp
echo PathFTPRoot=%2 ;Install path for FTP service >> %TEMP%\iisreloc.tmp
echo PathWWWRoot=%1 ;Install path for WWW service >> %TEMP%\iisreloc.tmp
sysocmgr /i:%windir%\inf\sysoc.inf /u:%TEMP%\iisreloc.tmp
echo Usage: iisreloc.cmd [wwwroot path] [ftproot path]
You can find out more information about creating the answer file on Microsoft’s website at http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/80455459-01b0-4961-aeab-081ce2eb03a4.mspx?mfr=true.
If you want to configure IIS during OS installation add the sections generated in the script, or described in the Microsoft document above to your unattended.txt or winnt.sif file.
If you wanted to install the IIS hive at D:\InetPub instead of C:\InetPub run the command file using the following syntax:
Iisreloc.cmd D:\InetPub\wwwroot D:\InetPub\ftproot