How to Rebuild the WMI Repository

In Microsoft computer systems, Windows Management Instrumentation (WMI) consists of a set of extensions to the Windows Driver Model that provides an operating system interface through which instrumented components provide information and notification. Windows Management Instrumentation (WMI) is an implementation of Web-Based Enterprise Management (WBEM), a standard that the Distributed Management Task Force (DMTF—an industry consortium) defines. The WBEM standard encompasses the design of an extensible enterprise data-collection and data-management facility that has the flexibility and extensibility required to manage local and remote systems that comprise arbitrary components. WMI uses the Common Information Model (CIM) industry standard to represent systems, applications, networks, devices, and other managed components. CIM is developed and maintained by the Distributed Management Task Force (DMTF).

WMI allows scripting languages (such as VBScript or Windows PowerShell) to manage Microsoft Windows personal computers and servers, both locally and remotely. WMI comes preinstalled in Windows 2000 and in newer Microsoft OSes. It is available as a download for Windows NT, Windows 95 and Windows 98.

Microsoft provides a Windows Management Instrumentation Command-line (WMIC) utility to WMI.

Winmgmt is the WMI service within the SVCHOST process running under the LocalSystem account. In all cases, the WMI service automatically starts when the first management application or script requests connection to a WMI namespace.

This tool is located in the %Windir%\System32\wbem directory. For a list of the available switches, type WinMgmt /? at the command prompt.

When run from the command prompt, the WMI service has the following switches.

How to Rebuild the WMI Repository K3sUZ9H

The WMI repository, also known as the CIM repository, is not just a single file, but a collection of files within the Repository folder that work together as a database. If you experience behavior when using WMI, such as application errors or scripts that used to work are no longer working, you may have a corrupted WMI repository. If the WinMgmt /verifyrepository command reports inconsistency for WMI repository then you have a corrupted WMI repository.

How to Rebuild the WMI Repository GR8RGh0

To fix a corrupted WMI repository, use these steps:

If WMI returns the error ERROR_INTERNAL_DB_CORRUPTION (net helpmsg 1358) if a verification operation indicates that the repository is not in a consistent state. This error can be returned from any command which performs repository verification, such as /verifyrepository or /salvagerepository. For to correct this error you may have to reset the WMI repository with WinMgmt  /resetrepository command, that is if you have not backup WMI repository and or WinMgmt /salvagerepository command cannot rebuilds the WMI repository.

1. For Windows XP with Service Pack 2 installed, click Start Menu --> Run and type the following command, and click OK button:

Code:

rundll32 wbemupgd, UpgradeRepository


This command is used to detect and repair a corrupted WMI Repository. The results are stored in the setup.log (%windir%\system32\wbem\logs\setup.log) file. If above command wont work then you need Windows XP Setup CD with same service pack installed on your Windows XP computer. If you don't have one, you may point to the %Windir%\ServicePackFiles\i386 folder for a recent version of the system files required during WMI repair. Or you may create a slipstreamed Windows XP CD and insert it when prompted.

2. Click Start Menu > Run and type the following command, and click OK button:

Code:

rundll32.exe setupapi,InstallHinfSection WBEM 132 %windir%\inf\wbemoc.inf


3. Insert your Windows XP Installation CD into CD/DVD optical drive when prompted. Repair process should take few minutes to complete. Then restart Windows for the changes to take effect.

3. For Windows Vista and later versions of Windows, open the Command Prompt by typing cmd.exe into Start Screen or Start Menu, right-click on Cmd.exe, and open it as an administrator.

Type following command and press Enter key:

Code:

winmgmt /salvagerepository


The above command Performs a consistency check on the WMI repository, and if an inconsistency is detected, rebuilds the repository. The content of the inconsistent repository is merged into the rebuilt repository, if it can be read.




Re-registering the WMI Components

The .DLL and .EXE files used by WMI are located in %windir%\system32\wbem directory. You might need to re-register all the .DLL files in this directory. If you are running a 64-bit system you might also need to  re-register all .DLL files in % windir%\sysWOW64\wbem directory. Batch script file attached to this tutorial will register .DLL files used by WMI, click the to download batch script file.

                                 




Rebuilding the WMI Repository

1. Open the Command Prompt by clicking Start Menu --> All Programs --> Accessories, right-click on Command Prompt, and open it as an administrator. In Windows Vista and later versions of Window operating systems type cmd.exe into Start Screen or Start Menu, right-click on Cmd.exe, and open it as an administrator.

2. Type following commands one at a time and press Enter key for each command you have typed:

Code:

net stop Winmgmt

Ren  %windir%\System32\Wbem\Repository   %windir%\System32\Wbem\Repository_bad

Net Start Winmgmt

Exit


3. Restart your computer.

Above commands will rename the %windir%\System32\Wbem\Repository folder to "Repository_bad".

This should rebuild the WMI Repository.


Did you find this tutorial helpful? Don’t forget to share your views with us.