11. April 2011 16:45
We are almost done phasing out our IIS 6 servers, but we have a couple left in production and a developer asked me if it’s possible to change the web site path in IIS 6 via command line so he could script out deployments. I’ve covered how to do this in IIS 7 in this article, but since appcmd is IIS 7 only, I had to figure out how to do it using other tools. After some research, I found you can run:
iisweb /create C:\Path\subfolder "SiteName" /d hostheader.domain.com
This will overwrite the existing site to change the path, but reset the application pool to the default app pool. One of the weaknesses of IIS 6 is it allows you to set different versions of .net in the same application pool, but then the application pool crashes once the second version tries to run. So this wasn’t the solution. Long story short, I opted just to alter the Metabase directly using the following command:
ADSUTIL.VBS set w3svc/111111/root/path “C:\Path\subfolder”
This changed path of site 111111 to C:\Path\subfolder, but kept the rest of the settings for the web site, including the application pool, IP bindings, host header settings, and virtual directory settings.