Continuing WMI Headaches: Rebuilding the Repository

Angry_mob_of_fourYou don’t work with WMI as much as we do without getting a number of headaches. For all of the functionality that WMI provides, it has contributed more than its fair share of clenched fists, muttered expletives, and harshly flung mice. WMI has a lot of moving parts, any one of which can break – leading to cranial pain.

WMI errors can can be caused by… well… by almost anything, including a stern look. One common cause of WMI problems is a corrupted repository. The repository is a collection of files that WMI maintains internally to define all of the classes and methods for its providers. If the repository gets corrupted, you’ll get all sorts of strange errors. Luckily, rebuilding the repository is quick so it’s a good place to start.

There are only 3 steps:

  1. Stop the WMI service: net stop winmgmt
  2. Delete (or rename, just in case) the repository directory: %windir%\system32\WBEM\Repository
  3. Start the WMI service: net start winmgmt

When WMI comes back up, it will rebuild its repository and *hopefully* eliminate the error. On the off chance that this makes things worse, just re-do the steps but put back the renamed repository from step 2.

Microsoft has a pretty in-depth article covering a variety of WMI troubleshooting techniques. They also have a tool for testing a WMI installation which I’ll cover in an article next week.