I made a script to make it easier to deal with the “Invalid namespace” error.

color icon icon by Icons8

When executing some programs, the message “Invalid namespace" appears.

I was able to fix it, but it was too much work for me, so I made a Power Shell to automate the process.

Errors and symptoms

  • Certain programs are getting an “Invalid namespace" error
  • “Windows Management Instrumentation" service is running.


A broken WMI repository is one of the causes of the “Invalid namespace" error.

If you get MOF files from “HKLMSoftwaremicrosoftWBEMCIMOMAutorecover MOFs" in the registry, compile them with mofcomp.exe, and register them in WMI repository, you may be able to repair them.

How to operate

  1. Right click on “Power Shell" and click “Run as administrator".
  2. Copy and paste the code below into the Power Shell screen and run it
  3. When the screen stops displaying, the process is complete.

It seems that there is a case that this method does not cure the symptoms, so if it doesn’t work, you have to do something else.