13

The folder C:\Windows\System32\wbem\ takes up almost 100 GB on my SSD drive. This doesn't feel like an optimal utilization of my SSD drive. Can it be reduced?

I've come across some references to "rebuilding your WMI repository" that seemed related to the wbem directory. So I've tried doing this, but the size did not decrease noticeably.

The content in the wbem directory is a lot of folders named repository.xxx where xxx is 001 to 096. These folders' sizes range from 758 MB to 1 140 MB. There is also a folder called merely repository, which is 1 078 MB in size.

I'm using Windows 8 Enterprise 64-bit (not Win 8.1). I just ran winmgmt /verifyrepository and got the result: WMI repository is consistent

Simeon
  • 133
  • 1
  • 1
  • 9

1 Answers1

12

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.

harrymc
  • 455,459
  • 31
  • 526
  • 924
  • Running `sfc /scannow` gave the result `Windows Resource Protection did not find any integrity violations`. I've now removed the folders and rebooted my computer, and is currently looking for any side effects – Simeon Oct 22 '13 at 07:49
  • One day after clearing the stuff out, I already have a 1 GB `repository` folder and a 1 GB `repository.001` folder... I guess that I will have to live with this and re-run the procedure when the folder gets too large. Un-accepting your answer due to not knowing how to prevent this – Simeon Oct 23 '13 at 08:09
  • 2
    You could maybe try the [WMI Diagnosis Utility](http://technet.microsoft.com/en-us/library/ff404265.aspx) and also do `"winmgmt /resetRepository`. Check the date/time on repository.xxx - if the hours are similar this might be a scheduled job. Check also the Event Viewer for interesting error messages relating to WMI. – harrymc Oct 23 '13 at 08:27
  • 1
    Impressed! `winmgmt /resetRepository` did it – Simeon Oct 23 '13 at 14:14
  • Is it that risky to create restore points and/or system image? I am unable to install Visual Studio Build Tools 2017 and people on stackoverflow are [suggesting](https://stackoverflow.com/a/43148261/1317018) to perform something like this to successfully install build tools – Mahesha999 Aug 27 '18 at 10:18
  • @Mahesha999: I recommend creating restore points and periodically a system image (and also before any forceful system manipulation). No harm possible, and they can be a life-saver. – harrymc Aug 27 '18 at 10:21