Share via

SQL Server 2022 setup fails: MOF compiler cannot connect to WMI server & PerfLib 2.0 counter removal failed

Alex Smith 0 Reputation points
2025-10-01T20:36:11.69+00:00

I’m trying to install SQL Server 2022 Developer Edition (64-bit) on Windows 11 Pro 24H2. The installer repeatedly fails with the following errors:

The following error has occurred:

The MOF compiler could not connect with the WMI server. This is either because of a semantic error such as an incompatibility with the existing WMI repository or an actual error such as the failure of the WMI server to start.

And also:
The following error has occurred:

PerfLib 2.0 counter removal failed with exit code -2147024894. Command line: C:\WINDOWS\system32\unlodctr.exe /m:hkengperfctr.xml from directory C:\Program Files\Microsoft SQL Server\160\Shared.

How can I fix these WMI/MOF compiler and PerfLib counter removal errors to successfully complete SQL Server 2022 installation?

Are there official Microsoft repair steps or a supported way to fully reset WMI / performance counters before retrying installation?

I have already tried multiple solutions from ChatGPT, YouTube tutorials, and blogs, but none of them solved the issue. At this point I need expert guidance or official Microsoft-supported steps to fix the WMI/MOF compiler and PerfLib counter errors so I can complete the SQL Server 2022 installation. Any detailed troubleshooting or proven solution would be greatly appreciated.

SQL Server Database Engine
0 comments No comments

Answer recommended by moderator
  1. Erland Sommarskog 133.7K Reputation points MVP Volunteer Moderator
    2025-10-01T21:10:48.4+00:00

    The performance-counter is usually benign. The other is not.

    Unfortunately, this is a difficult situation to recover from. First check, you have an x64 machine, haven't you? If you have an ARM machine, it's dead from the start. SQL Server does not run on ARM. (Well, you have success with LocalDB.)

    Else, my assumption is that these type of errors are due to previously failed installations followed by some random cleanup which messed up things more. Some people have reported success after having followed this article: https://www.sql-easy.com/learn/how-to-uninstall-sql-server/ But there also who have tried it, and who came no further.

    You also read this article: https://learn.microsoft.com/en-us/troubleshoot/sql/database-engine/database-file-operations/troubleshoot-os-4kb-disk-sector-size. It discusses a known issue where Windows 11 reports a disk-sector size that SQL Server cannot handle. This is not what causing the failure with the MOF compiler, but it could be the reason for the original failure.

    If that does not work out, your best bet may be to create a virtual machine and run SQL Server from the VM.

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Akhil Gajavelly 1,735 Reputation points Microsoft External Staff Moderator
    2025-10-06T09:24:25.7033333+00:00

    Hi @ Alex Smith,

    These WMI/MOF and PerfLib errors mean your WMI repository is corrupted. Follow these exact steps this works for you.

    Run as Administrator (CMD):
    net stop winmgmt
    winmgmt /verifyrepository
    winmgmt /salvagerepository
    winmgmt /resetrepository
    mofcomp %windir%\system32\wbem\cimwin32.mof
    mofcomp %windir%\system32\wbem\cimwin32.mfl
    lodctr /R
    winmgmt /resyncperf
    Then restart Windows.

    Remove old SQL traces Use this clean uninstall guide:  https://www.sql-easy.com/learn/how-to-uninstall-sql-server/

    Reinstall SQL Server 2022 Developer Run setup.exe → Run as Administrator.

    If still failing, install inside a clean Windows 11 x64 VM guaranteed success.

    Thanks,
    Akhil.

    1 person found this answer helpful.

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.