If repository is found to be inconsistent, for Vista and newer, run from elevated command prompt:
Winmgmt /salvagerepository
Note this command will take the content of the inconsistent repository and merge it into the rebuilt repository if it is readable
If the above doesn’t work, then run:
Winmgmt /resetrepository
Note this will reset repository to the initial state when the OS was first installed
~pouyan