Tuesday, September 30, 2008

Windows Management Instrumentation failed on SQL 2008 Installation

So here's the situation: I'm trying to install SQL Server 2008 on Windows Server 2005, with a pre-existing instance of SQL 2005. When I initialized the install, SQL 2008 threw an error over Windows Management Instrumentation (WMI), and the error message lead one to think that the WMI service was not installed / running.

A quick check of my services confirmed that WMI was in fact running, and restarting the service as well as restarting the entire server did not resolve my issues.

I had found a couple BAT scripts that claimed to fix the issue like:

%SYSTEMDRIVE%
CD %windir%\system32\wbem
Mofcomp.exe cimwin32.mof
Regsvr32 /s wbemupgd.dll
Regsvr32 /s wbemsvc.dll
wmiprvse /regserver

The line Mofcomp.exe cimwin32.mof actually threw an error (Error Number: 0x80041014, Facility: WMI), but the error number only turned up this post on the Microsoft Forums, which did not help my problem. In fact the wbemtest.exe itself threw a WMI error at me when I tried to connect to "root\cimv2"

In digging through the server, and playing with the MOF files / mofcomp, it looks to me like my repository was corrupted somehow, and completely deleting the direcory did not help (in fact I would suggest against it! ).

Finally I found the holy grail of scripts, which did in fact fix my problem. Simply copy the script below, paste it into a file on your server / machine, save it as a .bat file, and run it. You might want to step away from the computer for a while, because it might take a while.

And finally, the script:

net stop winmgmt /y

c:

cd %systemroot%\system32\wbem

if exist %systemroot%\system32\wbem\repository.old rmdir /s /q

repository.old

rename %systemroot%\system32\wbem\repository repository.old

regsvr32 /s %systemroot%\system32\scecli.dll

regsvr32 /s %systemroot%\system32\userenv.dll

mofcomp cimwin32.mof

mofcomp cimwin32.mfl

mofcomp rsop.mof

mofcomp rsop.mfl

for /f %%s in ('dir /b *.dll') do regsvr32 /s %%s

for /f %%s in ('dir /b *.mof') do mofcomp %%s

for /f %%s in ('dir /b *.mfl') do mofcomp %%s

-----------------------------------------------------------

%systemroot%\system32\wbem\winmgmt /clearadap

%systemroot%\system32\wbem\winmgmt /kill

%systemroot%\system32\wbem\winmgmt /unregserver

%systemroot%\system32\wbem\winmgmt /regserver

%systemroot%\system32\wbem\winmgmt /resyncperf

net stop winmgmt /y

if exist %systemroot\system32\wbem\repository.old rmdir /s /q

repository.old

rename %systemroot\system32\wbem\repository repository.old

regsvr32 -s %systemroot%\system32\scecli.dll

regsvr32 -s %systemroot%\system32\userenv.dll

mofcomp %systemroot%\system32\wbem\cimwin32.mof

mofcomp %systemroot%\system32\wbem\cimwin32.mfl

mofcomp %systemroot%\system32\wbem\rsop.mof

mofcomp %systemroot%\system32\wbem\rsop.mfl

for /f %%s in ('dir /b *.dll') do regsvr32 /s %%s

for /f %%s in ('dir /b *.mof') do mofcomp %%s

for /f %%s in ('dir /b *.mfl') do mofcomp %%s

net start winmgmt

%systemroot%\system32\wbem\wmiprvse /regserver




END OF SCRIPT DON'T COPY ANYMORE!!!!!!!!!!!!!!

I can't take credit for this script, I found it here but it was kind of painful digging it out of all of the other crap on the page......

Anyway, peace!
~M.

7 comments:

Muthukumar Selvarasu said...

Hey bro, you done a great job.

Cheers
Muthukumar Selvarasu

webmaster said...

Thanks.
You save my day.

Urvij said...

Thank you so much. You saved me lot of frustration.

Batbold said...

Thank you for your post. It's work great.

Batbold said...

Thank you for your post. It works great.

m.sab said...

Great job,Thank you very much

Chandan said...

Thanks for the post. This resolved my other issues as well.