Rebuild the Windows WMI Repository

For my first technical post, I’ll try to keep things relatively quick and simple.

Rebuilding the WMI Repository is something that’s pretty well documented in various outlets, including Technet, but it’s been so useful to myself and many of my colleagues that I’d like to share it here.

As mentioned in the linked article: “The WMI Repository “%windir%System32\Wbem\Repository” is the database that stores meta-information and definitions for WMI classes; in some cases the repository also stores static class data as well. If the Repository becomes corrupted, then the WMI service will not be able to function correctly.”

In my personal experience, rebuilding the WMI repository has come in most handy when repairing the SCCM 2007 client after it stops working properly on Windows 7 systems, so if you’re an SCCM Admin and can’t figure out why some of your clients aren’t receiving advertisements, consider giving this a try. I imagine this could also be useful when troubleshooting issues for almost any application or service that relies on WMI. However, please keep in mind that this is generally recommended AS A LAST RESORT because, again from said article, “Deleting and rebuilding the repository can cause damage to the system or to installed applications”, so proceed with caution.

To repair the local WMI repository in Windows:

  1. Open an elevated command prompt
  2. Type net stop winmgmt and hit Enter. This stops the WMI service. (Side note: I’ve had instances where the WMI service is unable to stop after running this command. If this is the case, open the Services applet and set the Windows Management Instrumentation service Startup Type to Disabled and reboot the computer before proceeding)
  3. Use Windows Explorer to navigate to: %systemroot\system32\wbem
  4. Delete or rename the Repository folder (I usually like to add .old to the end of the folder name, so Repository.old)
  5. Return to the elevated command prompt and enter: net start winmgmt (Set the Startup Type back to Automatic for the WMI service first if you disabled it previously)
  6. Enter: cd /d %windir%\system32\wbem
  7. Re-register the dlls by entering: for %i in (*.dll) do RegSvr32 -s %i
  8. Reboot the system

These steps might differ a little bit from what you might find elsewhere, but this process has always worked well for me and my colleagues.

The Technet article that I referenced previously also lists some additional commands that you can run to verify and repair the WMI repository automatically on Windows Vista and above, but I haven’t tested them myself so I can’t vouch for their effectiveness. Those commands are:

  • winmgmt /verifyrepository  checks the WMI repository for consistency
  • Winmgmt /resetrepository – resets the WMI repository back to its initial state after the OS was first installed

So there you have it. This post didn’t turn out nearly as short and concise as I hoped, but this trick is something that I always keep well documented and close at hand, so I hope someone else is able to find it useful.



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s