After troubleshooting and attempting many of the recommended solutions and none working from Blizzard Tech Support and not finding this posted elsewhere on the forums, this method resolved many of the endless Agent.exe not installing after being uninstalled, Update Agent Loops and unhelpful “BLZBNTAGT0000138F - Whoops! Looks like something broke. Give it another shot.” errors, etc. I was having and allowed the Battle Net Agent to be installed and work correctly again.
Rebuild your WMI Repository:
While Blizzard’s recommend method for resetting the WMI Repository (hxxps://us.battle[.]net/support/en/article/257703) may work in some cases, a better more comprehensive solution is rebuilding the WMI repository using this method (hxxps://techcommunity.microsoft[.]com/t5/ask-the-performance-team/wmi-rebuilding-the-wmi-repository/ba-p/373846) which works on Windows 10 and below:
You should also note to make a save point/back up before you rebuild the WMI repository.
Re-register all of the dlls and recompile the .mofs in the wbem folder and re-registering WMI Service and Provider. You can use the following script by saving to txt file then renaming to .bat and running from command prompt or powershell prompt with admin rights and changing focus to following directory: C:\Windows\System
Create batch file using this script:
@echo off
sc config winmgmt start= disabled
net stop winmgmt /y
%systemdrive%
cd %windir%\system32\wbem
for /f %%s in (‘dir /b *.dll’) do regsvr32 /s %%s
wmiprvse /regserver
winmgmt /regserver
sc config winmgmt start= auto
net start winmgmt
for /f %%s in (‘dir /s /b *.mof *.mfl’) do mofcomp %%s
To run this script:
- Open Notepad.
- Copy and paste the above code into Notepad.
- Save the file with a .bat extension (for example, wmi-rebuild.bat).
- Right-click on the saved file and select “Run as Administrator”.
- Reboot the machine and test WMI
Next, check the repository for consistencies:
For Windows 7 and above, you can run from an elevated command or powershell prompt.
winmgmt /verifyrepository
If repository is found to be inconsistent:
a. For Windows 7 and newer, run from elevated command or powershell 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 the repository to the initial state when the OS was first installed
Again, it’s important to note that this script makes changes to system-level settings and should be used carefully. Running such scripts can potentially cause system instability if not used correctly. Always ensure you have a backup of any important data before running such scripts.