Working with IIS 6 Scriptmaps inheritance

Categories:

One thing that always seems to trip up people new to IIS is the metabase, and when dealing with things such as inheritance sometimes it is quite understandable. Take the scriptmaps property for instance, which is where your application mapping information is stored in the metabase. By default this property is inherited from the root at W3SVC, but when people install applications such as PHP or PERL they sometimes inadvertently break this inheritance chain. This is because the scriptmap property is not only set at the global level, but also the site, directory and virtual directory level which overides the global settings. The problem this causes is that the next time an application mapping is made at the global level it is not inherited by any site, directory or virtual directory with the scriptmap property set. This can lead to a complicated environment and also effect IIS performance in more extreme cases due to the metabase being so bloated. In this article we'll look at a simple way in which you can manage the scriptmaps property en masse.

The best way to manage a large amount of ScriptMaps is usually via the command line, as it is actually possible that you are unable to access your ScriptMaps through the GUI interface. If you create an IIS application anywhere in IIS, create/modify/delete an application mapping for it and then remove that IIS application you'll have a ScriptMaps property that can't be accessed via the GUI as the "configuration" button will now be greyed out. This is because when you create an application mapping for an IIS application the ScriptMaps property is created. However when you remove the IIS application only the AppRoot, AppIsolated and AppFriendlyName properties are removed, leaving the ScriptMaps property there and active. From here the only way to access this ScriptMaps property is to recreate the IIS application in the GUI, modify an application mapping further up the tree and select the overide option or use the command line. In this article we'll be using the ever useful adsutil.vbs tool that comes with IIS on a search and destroy mission of unwanted ScriptMaps properties.

First thing to do is get a listing of where all the ScriptMaps properties are. To do this open a command prompt then navigate to you inetpub\adminscripts directory and enter the following command;

adsutil.vbs FIND scriptmaps|find "W3SVC/" > scriptmaps.txt

This will output the location of all ScriptMaps properties in your metabase except for the one located in the metabase root (as you don't want to remove this one). Open the file called scriptmaps.txt and you should see something like this;

  W3SVC/87257621/root
  W3SVC/87257621/root/test
  W3SVC/87257621/root/files
  W3SVC/223085047/root

The next step is to remove any entries you wish to keep and then save the file. Use the website identifier which is always the number that is displayed between "W3SVC/" and "/root" to find which websites these paths relate to. Before moving onto the next step I highly recommend that you backup you IIS metabase as a matter of good practice before making any configuration changes.

Now it is time to remove the ScriptMaps properties listed in your scriptmaps.txt file from the earlier step. Copy the following code to a new file in the same location as the adsutil.vbs tool and your scriptmaps.txt file, and make sure the file ends with a .cmd or .bat extension;

@echo off
FOR /F %%I IN (scriptmaps.txt) DO adsutil.vbs DELETE %%I/ScriptMaps
adsutil FIND scriptmaps|find "W3SVC/"

Go back to you command prompt from earlier and enter the filename you created with the above code in it and press enter. You should see the output of the adsutil.vbs tool looping though and deleting the ScriptMaps property from each of the locations specified in scriptmaps.txt. After that is complete adsutil.vbs will search through the metabase again for the remaining ScriptMaps properties where the output should only contain those locations you removed from the scriptmaps.txt file.

Hopefully this should help those having issues with getting application mappings to work due to inheritance issues. Please feel free to comment or post in the forums if you need any help.

Average rating
(3 votes)