Why is my c:\windows\system32\wbem folder almost 100 GB and how do I reduce it?

Solution 1:

There should only be one copy of C:\Windows\System32\wbem\Repository.

The Repository.xxx folders might be WMI repository backups generated each time that you repair the repository or recreate it. It was once intended for the SCCM client agent to automatically try to rebuild the WMI repository if there was a consistency issue detected, a feature which might still exist and be the issue you are running into.

I do not know why you have so many of these folders, but it seems that WMI has an issue on your computer. As a first-aid, you could get rid of all these folders and rebuild the repository.

See also if the article Configuration Manager Client Health – Disable Automatic Remediation relates to your setup, as it contains a registry fix for a similar problem.

It also wouldn't hurt to run the sfc /scannow command.

The simplest WMI rebuild is done via :

  1. net stop winmgmt
  2. Move elsewhere all folders named C:\Windows\System32\wbem\Repository*
  3. net start winmgmt (should start rebuilding the repository)
  4. Wait a while and then reboot
  5. If everything works fine, you can junk the saved folders.

A WMI repair script that has been knocking around since ages (but I have never tried) might itself or in some parts-of still be useful on Windows 8 :

Echo Fix WMI
net stop winmgmt /y
if exist %windir%\system32\wbem\repository.001 rmdir /s /q %windir%\system32\wbem\repository.001
rename %windir%\system32\wbem\repository repository.001
%windir%\system32\wbem\winmgmt /clearadap
%windir%\system32\wbem\winmgmt /kill
%windir%\system32\wbem\winmgmt /unregserver
%windir%\system32\wbem\winmgmt /reserver
%windir%\system32\wbem\winmgmt /resyncperf
regsvr32 /s %systemroot%\system32\scecli.dll
regsvr32 /s %systemroot%\system32\userenv.dll
mofcomp %windir%\system32\wbem\cimwin32.mof
mofcomp %windir%\system32\wbem\cimwin32.mfl
mofcomp %windir%\system32\wbem\rsop.mof
mofcomp %windir%\system32\wbem\rsop.mfl
cd \windows\system32\wbem
for /f %%s in ('dir /b /s %windir%\system32\wbem\*.dll') do regsvr32 /s %%s
for /f %%s in ('dir /b /s %windir%\system32\wbem\*.mof') do mofcomp %%s
for /f %%s in ('dir /b %windir%\system32\wbem\*.mfl') do mofcomp %%s
net start winmgmt
%windir%\system32\wbem\wmiprvse /regserver
%windir%\system32\wbem\winmgmt /regserver

After all this, you might reboot and run once more winmgmt /verifyrepository.

Be very careful with backups and create at least a system restore point before starting, or even better : take an image snapshot of the system disk.