Thursday, January 15, 2009

Fearlessly tweak IIS

I find that I wreck my development machine often, either because I over-tweak or because I a messing with something that I have never messed with before.

IIS on Vista / Server 2008 is one of those things where messing with it outside of the configuration interface can really jack things up - almost to the point of having to reinstall IIS or even your OS.

I came across this a while back (I can't remember the source, so credit can go to the tech fairy) - before messing with IIS (even through the configuration panel) you should backup the configuration files IIS uses - here's how...

Let's go really low-tech and create a simple bat file to get the job done:
  1. Create a new bat file and name it something like: backupiis.bat
  2. Put the following code in it (changing the value of DestPath) -
    SET DestPath=e:\backups\

    @For /F "tokens=2,3,4 delims=/ " %%A in ('Date /t') do @(
    Set Month=%%A
    Set Day=%%B
    Set Year=%%C
    )

    copy C:\Windows\Microsoft.NET\Framework\v2.0.50727\CONFIG\machine.config %DestPath%machine.config_%Year%%Month%%Day%
    copy C:\Windows\System32\inetsrv\config\applicationHost.config %DestPath%applicationHost.config_%Year%%Month%%Day%
  3. Execute by double clicking on the bat file or setup a scheduled task
Now you can fearlessly go tweak IIS!

No comments:

Post a Comment