How to repair (rebuild) the WMI repository on Windows

Repair the WMI repository by running winmgmt /verifyrepository in an elevated Command Prompt, then winmgmt /salvagerepository if it reports an inconsistency.

This guide covers checking the repository, backing it up, recompiling MOF files, a full rebuild as the last resort, and fixes for WMI connection and access errors on Windows 11, Windows 10 and Windows Server.

How to repair (rebuild) the WMI repository on Windows
The WMI repository sits behind the WMI service, which management apps and WMI providers reach over COM/DCOM and RPC. (Image: Microsoft)

Repair the WMI repository with winmgmt /salvagerepository

The salvage switch checks the repository and rebuilds it only if it finds damage. Anything it can still read from the old repository is merged into the rebuilt one, so it is the safest repair.

  1. Select Start, type cmd, right-click Command Prompt and choose Run as administrator.
  2. Run winmgmt /verifyrepository to check the live repository.
  3. If the result says the repository is inconsistent, or returns error 1358 (ERROR_INTERNAL_DB_CORRUPTION), run winmgmt /salvagerepository.
  4. Run winmgmt /verifyrepository again and confirm it now reports a consistent repository.
  5. Restart the PC, or the app that reported the WMI error, and test it again.

WMI errors do not always mean the repository is damaged. Failures elsewhere in Windows surface through WMI, so check the error code against the troubleshooting section before going further than a salvage.

WMI repository repair options: verify, salvage, reset or restore

Your situation Use this What it changes
WMI errors, cause unknown winmgmt /verifyrepository Nothing; consistency check only
Verify reports an inconsistent repository winmgmt /salvagerepository Rebuilds and merges readable data back in
Classes missing or providers fail to load after salvage Re-register provider DLLs and recompile MOF files Re-adds built-in classes and providers
You have a backup from before the problem winmgmt /restore <file> 0 Replaces the repository with the backup
Every other repair failed winmgmt /resetrepository Returns the repository to its install-time state

Check the WMI repository with winmgmt /verifyrepository

Run this first, in an elevated Command Prompt. It reads the live repository that WMI is using and changes nothing.

winmgmt /verifyrepository

Performs a consistency check on the WMI repository currently in use. Add a full folder path after the switch to check a saved copy of the whole Repository folder instead.

You should see: A consistent result means the repository is not your problem. Error 1358, ERROR_INTERNAL_DB_CORRUPTION, means it is inconsistent and needs a salvage.

Back up the WMI repository with winmgmt /backup

Take a backup before any salvage, recompile or reset. The repository is a folder of files that work as a database, and the backup packs it into one compressed file.

winmgmt /backup C:\WMIBackup\repository.bak

Writes the whole repository to the file you name. Give the full path; without one, the file lands in %Windir%\System32. Writes to the repository pause until the backup finishes.

You should see: The .bak file exists at the path you gave. Restore it later with winmgmt /restore C:\WMIBackup\repository.bak 0, or use 1 instead of 0 to disconnect connected clients and restore anyway.

Repair the WMI repository and recompile the MOF files

When salvage leaves classes missing or providers failing, re-register the WMI provider DLLs and recompile the MOF files in the wbem folder. This covers the built-in providers and any placed in the default path.

Run every command in an elevated Command Prompt, typed directly at the prompt. Inside a .bat file, the %s variables need to be written as %%s.

  1. Set the WMI service to disabled: sc config winmgmt start= disabled.
  2. Stop it and its dependent services: net stop winmgmt /y.
  3. Switch to the system drive with %systemdrive%, then run cd %windir%\system32\wbem.
  4. Re-register the provider DLLs: for /f %s in ('dir /b *.dll') do regsvr32 /s %s.
  5. Set the service back to automatic: sc config winmgmt start= Auto.
  6. Start it again: net start winmgmt.
  7. Recompile the MOF and MFL files, skipping uninstall files: dir /b *.mof *.mfl | findstr /v /i uninstall > moflist.txt & for /F %s in (moflist.txt) do mofcomp %s.

Stopping winmgmt also stops services that depend on it, such as Windows Firewall, and they do not all restart on their own. Restart the PC after the recompile so every dependent service comes back.

Rebuilding the WMI repository in Windows

A reset returns the repository to the state it had when Windows was installed. WMI loses everything it gathered since then about the system, apps and services, and Microsoft recommends a rebuild only under Microsoft support guidance.

Only MOF files that contain the #pragma autorecover statement are restored automatically. Classes from other software return only when that software recompiles its MOF files or is reinstalled.

  1. Back up the current repository with winmgmt /backup and a full file path.
  2. Open Command Prompt as administrator.
  3. Run winmgmt /resetrepository.
  4. Restart the PC.
  5. Run winmgmt /verifyrepository to confirm the new repository is consistent.
  6. Reinstall or repair any management agent or app that now reports missing WMI classes.

If the reset makes things worse, restore the backup with winmgmt /restore <full path to file> 1. WMI keeps the existing repository and writes it back if the restore fails.

Winmgmt command switches for the WMI repository

Winmgmt.exe lives in %Windir%\System32\wbem and runs as the Windows Management Instrumentation service (service name winmgmt) under LocalSystem. Type winmgmt /? to list the switches.

Switch What it does Risk
/verifyrepository [path] Consistency check of the live repository or a saved copy None
/salvagerepository Checks, rebuilds if inconsistent, and merges readable content back Low
/backup <filename> Saves the repository to one compressed file None; writes pause briefly
/restore <filename> <0 or 1> Restores a backup; 1 forces connected clients off Medium; replaces current data
/resetrepository Returns the repository to its install-time state High; collected data is lost
/resyncperf <PID> Re-registers performance libraries with WMI Low; only for unreliable performance classes

Test WMI after the repair with WMI Control and WBEMTEST

  1. Run winmgmt /verifyrepository in an elevated Command Prompt and confirm it reports a consistent repository.
  2. Press Win + R, type wmimgmt.msc and press Enter.
  3. Right-click WMI Control and select Properties; no failed-to-connect message should appear.
  4. Select Start, type wbemtest, right-click it and choose Run as administrator.
  5. Select Connect, keep the default root\cimv2 namespace and select Connect again; the main window should show it is connected.
  6. Run the app or script that first reported the WMI error.
Test WMI after the repair: WMI Control Properties failed to connect, WMI Not found
If WMI Control still shows this failed-to-connect message after a salvage, re-register providers and recompile the MOF files. (Image: Microsoft)

Troubleshooting WMI connectivity and common issues on Windows

Match the error code to a group. Connection and permission errors are not repository damage, and a repository rebuild will not fix them.

WMI Control says "WMI: Not Found", "WMI: Generic failure" or "The system cannot find the path specified"

A glitch or corruption in the local WMI repository.

  1. Run winmgmt /verifyrepository as administrator.
  2. If it reports an inconsistency, run winmgmt /salvagerepository.
  3. If the error remains, re-register the providers and recompile the MOF files as shown above.

0x80041002 WBEM_E_NOT_FOUND or 0x80041010 WBEM_E_INVALID_CLASS

The query names a class that is missing, which repository corruption can cause.

  1. Confirm the class name and namespace are spelled correctly.
  2. Verify and salvage the repository.
  3. Recompile the MOF file of the product that owns the class, or repair that product.

0x800706BA "The RPC server is unavailable"

The remote computer is unreachable or Windows Firewall blocks WMI.

  1. Confirm the target computer is on and reachable by name.
  2. On the target, run netsh advfirewall firewall set rule group="windows management instrumentation (wmi)" new enable=yes as administrator.
  3. Check whether the Restrict Unauthenticated RPC clients policy is set under Computer Configuration > Administrative Templates > System > Remote Procedure Call.

0x80070005 E_ACCESS_DENIED

DCOM security denies the user remote access.

  1. On the target, press Win + R, type dcomcnfg and press Enter.
  2. Expand Component Services > Computers, right-click My Computer and select Properties.
  3. On the COM Security tab, select Edit Limits under Launch and Activation Permissions.
  4. Add the user and allow Remote Launch and Remote Activation, then select OK.
  5. Or add the user to the local Distributed COM Users group.

0x80041003 WBEM_E_ACCESS_DENIED

The user lacks permission on the WMI namespace.

  1. Open wmimgmt.msc, right-click WMI Control and select Properties.
  2. On the Security tab, select the namespace, such as Root\cimv2, and select Security.
  3. Add the account and allow Remote Enable and Read Security.
  4. Select Advanced and set Applies to to This namespace and subnamespaces if child namespaces need the same access.

WMI queries fail and you need the exact error

The client hides the underlying code.

  1. Open Event Viewer.
  2. Go to Applications and Services Logs > Microsoft > Windows > WMI-Activity > Operational.
  3. Find the failed query and note its error code, then match it to a group above.
Fix WMI access denied errors with Remote Enable on the CIMV2 namespace
For 0x80041003 access denied, allow Remote Enable and Read Security and apply to this namespace and subnamespaces. (Image: Microsoft)

Should you delete the WMI repository folder?

No. Never delete or rename the Repository folder as a first step; use /verifyrepository and /salvagerepository instead. Microsoft warns that deleting the repository can damage Windows and installed applications, and many WMI errors come from other parts of the system rather than the repository itself.

Windows can also restore the repository from its own backup when it detects corruption. That AutoRestore behaviour is controlled by the AutoRestoreEnabled value under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WBEM\CIMOM, where 1, the default, means enabled.

WMI repository repair FAQ

How do I know if the WMI repository is corrupted?

Run winmgmt /verifyrepository in an elevated Command Prompt. If it reports the repository is inconsistent or returns error 1358, ERROR_INTERNAL_DB_CORRUPTION, it is damaged. Errors such as WMI: Not Found or Generic failure in WMI Control also point to repository trouble.

What is the difference between salvagerepository and resetrepository?

Salvage checks the repository and rebuilds it only if it is inconsistent, merging back any content it can still read. Reset discards everything and returns the repository to its install-time state, restoring only MOF files marked with #pragma autorecover.

Is it safe to rebuild the WMI repository?

A salvage is low risk. A full reset is not: WMI loses the data it gathered about the system, apps and services, and Microsoft recommends a rebuild only with Microsoft support. Back up the repository with winmgmt /backup before either one.

Where is the WMI repository stored?

The repository, also called the CIM repository, is a collection of files in a folder named Repository that work together as a database. Winmgmt.exe itself sits in %Windir%\System32\wbem. Change the repository only through winmgmt switches, never by editing or deleting its files.

How do I restart the WMI service?

Open Command Prompt as administrator and run net stop winmgmt, then net start winmgmt. Stopping it also stops dependent services such as Windows Firewall, which do not all restart automatically, so restarting the PC is the cleaner option.

Can I still use WMIDiag to diagnose WMI problems?

No. Microsoft ended support for the WMI Diagnosis Utility starting with Windows 8 and Windows Server 2012. Use winmgmt /verifyrepository, the WMI-Activity Operational event log and WBEMTEST instead.

Philip Celasco

Philip is a Texas-based technology writer and IT administrator at Techdows.com with more than 10 years of experience creating practical content for everyday users and professionals. He specializes in web browsers, particularly Chromium-based platforms such as Google Chrome, Microsoft Edge, Brave, and Opera. Through his work as an IT administrator, Philip has hands-on experience managing devices, configuring browser policies, troubleshooting software and network issues, and helping people resolve problems that affect productivity and security. His articles are based on practical testing and real-world technical experience. He covers browser settings, extensions, performance problems, privacy controls, security features, and Windows troubleshooting. Outside work, Philip enjoys the quieter side of life in Texas and stepping away from the screen when he can. He has two kids, two cats and loves to play golf with his mother during the weekends.

Leave a Reply

Your email address will not be published. Required fields are marked *