mercoledì 2 novembre 2011

Could not start the IIS Admin Service on Local Computer

When I try to start the IIS Admin Service from services.msc I receive the following error:

Could not start the IIS Admin Service on Local Computer
Error2: The system cannot find the file specified.
At the same time I can also see the following message in the System event log:

Error: The IIS Admin service terminated with the following error. The system cannot find the file specified

Source Name: Service Control Manager

Event ID: 7023

This error usually occurs when the MetaBase.xml file is either missing or has been corrupted. MetaBase.xml is the file wherein the IIS 6 configurations are written to and read from.

The default location for MetaBase.xml is C:\WINDOWS\system32\inetsrv\ . The default location for MetaBase.xml file back up is C:\WINDOWS\system32\inetsrv\History\
To solve this problem you can either restore the copy of the MetaBase.xml file (If you have a separate backup) or grab a copy from the History folder and place it in the C:\WINDOWS\system32\inetsrv\ folder. After which rename it to MetaBase.xml. Rename it to MetaBase.xml? Yeah! That's because in the History folder you will find the backup in the form MetaBase_0000000244_0000000000.xml . Subsequently, you will also find backups of the MBSchema.xml in the same format.

The MetaBase.xml file is backed up whenever you make any configurational changes to websites, application pools or any IIS related settings. By default, C:\WINDOWS\system32\inetsrv\History\ contains 10 most recent backups. However, this property itself can be changed from MetaBase.xml. Here's how to do it,

Open up Metabase.xml file in your favorite text editor. Now look for the section that says IIsComputer. In this section you will find an entry which says, "MaxHistoryFiles". By default, the value of this property is set to 10. You can change that value to whatever you want. Save the changes and start the IIS Admin Service.

All said, this is not the recommended way of changing the MetaBase.xml file :) Do not change the Metabase.xml file directly until you are very certain of what you are doing. But, if not this way then how? Very simple, just run the following command from the command prompt:
cscript.exe adsutil.vbs set /MaxHistoryFiles "12"
As you can notice I am changing the value of the maximum history file to 12. You can place any number there that you want. Now here's something interesting! There may be cases where in you will open the MetaBase.xml file after running the above command and do not see your change reflected. The changes only reflected after you restart the IIS Admin Service. Well that's because you do not have Enable Direct MetaBase Edit check box selected in the IIS properties. To see the changes take effect instantaneously run this command from the command prompt:

cscript.exe adsutil.vbs set /EnableEditWhileRunning "1"
Note: Sometimes after you restart the IIS admin service, the websites are in stopped state and you will have to start them manually to get going.

Update 21/08/2008: I wouldn't want you to enable Direct Metabase Edit for this scenario, as I figured out that when you use Adsutil.vbs the changes are made into the IN-MEMORY metabase.They will be reflected instantaneously in your environment and will then be written to the physical Metabase.xml after 2 mins.
Now you are all set to reflect changes as soon as they are made. However never do this on a production box. This was shown for instructional purposes so that we move along quickly. :) To de-select the Enable Direct MetaBase Edit check box run this command

cscript.exe adsutil.vbs set /EnableEditWhileRunning "0"
Problem solved and we also know a little about MetaBase.xml file now.

Nessun commento: