Repair and Rebuild the WMI Repository on Windows
In this article
Yes—you can repair and rebuild the Windows Management Instrumentation (WMI) repository using built‑in tools, and the process restores system‑wide monitoring and scripting functionality.
The WMI repository stores the CIM (Common Information Model) classes that Windows services and third‑party applications query for hardware, software, and configuration data. Corruption can cause errors such as "Invalid class" or "Provider load failure," leading to broken Device Manager, Event Viewer, or PowerShell scripts. Before you begin, make sure you have a local administrator account and a recent system restore point or backup, because the repair replaces the repository files.
What You'll Need
- Administrator rights on the computer
- Access to an elevated Command Prompt or PowerShell window
- Optional: a recent system restore point or full backup
Step‑By‑Step
- Open an elevated Command Prompt: press Win+X and choose Command Prompt (Admin) or Windows PowerShell (Admin). If the menu shows Terminal, select that and then run
cmdas administrator. - Stop the WMI service to prevent new queries while you work. Type
net stop winmgmt /yand press Enter. The/y flag forces dependent services to stop as well. - Rename the current repository folder as a safety backup. Enter the following command:
ren %windir%\System32\wbem\Repository Repository.old - Delete the repository's index files, which may be corrupted. Run:
del /f /s /q %windir%\System32\wbem\*.dlldel /f /s /q %windir%\System32\wbem\*.exe - Re‑register the core WMI components. Execute each line in order:
cd /d %windir%\System32\wbemfor %i in (*.dll) do regsvr32 /s %ifor %i in (*.exe) do %i /RegServer - Rebuild the repository by forcing WMI to recompile the MOF files. Run:
mofcomp %windir%\System32\wbem\*.mofmofcomp %windir%\System32\wbem\*.mfl - Restart the WMI service. Type
net start winmgmt. You should see a confirmation that the service started successfully. - Verify the repair. Open PowerShell and run
Get-WmiObject -Class Win32_OperatingSystem. If the command returns OS details without error, the repository is functional.
Common Mistakes
- Skipping the backup step: Deleting the repository without a backup can make recovery harder if the rebuild fails.
- Running commands in a non‑elevated window: Without admin rights the
net stopandregsvr32commands will fail silently. - Using the wrong folder path: The repository lives in
%windir%\System32\wbem\Repository. Typing a similar but incorrect path may rename the wrong folder. - Interrupting the process: Closing the command window before all steps finish can leave the repository half‑rebuilt, causing further errors.
Tips
- Run
winmgmt /verifyrepositorybefore starting; it reports the current health status. - If the repository is only partially corrupted, you can try
winmgmt /salvagerepositoryfirst; it attempts an automatic fix without full rebuild. - After a successful rebuild, run
winmgmt /resetrepositoryto clear any lingering caches. - Keep a copy of the
Repository.oldfolder for a few days; delete it only after you confirm all services work.
Troubleshooting
If the WMI service fails to start after the rebuild, follow these steps:
- Check the Event Viewer under Windows Logs → Application for entries with source
WMI. Look for error codes such as 0x80041001 (provider load failure). - Run
sfc /scannowto repair any corrupted system files that might affect WMI. - Execute
dism /online /cleanup-image /restorehealthto fix component store issues. - If the service still won’t start, repeat the rebuild but this time use the
winmgmt /resetrepositorycommand before step 5 to force a fresh start. - As a last resort, perform an in‑place upgrade (repair install) of Windows. This refreshes system files while preserving apps and data.
Frequently Asked Questions
Will rebuilding the repository delete my installed programs?
No. The repository only holds metadata about system components; programs remain installed. However, some third‑party tools that rely on custom WMI classes may need to reinstall their providers.
Can I automate this process with a script?
Yes. A batch file containing the commands from the Step‑By‑Step section can be run with administrative privileges, but always test on a non‑critical machine first.
What if I get "Access denied" when running net stop winmgmt?
Make sure the command window is truly elevated. Right‑click the Start button, choose Windows PowerShell (Admin), and re‑run the command.
Is there a GUI way to repair WMI?
Windows does not provide a dedicated graphical tool for WMI repair. The command‑line method is the officially supported approach.
Do I need to reboot after the rebuild?
A reboot is not required if the service starts cleanly, but restarting the computer can help ensure all dependent services pick up the refreshed repository.