SQL SERVER – WMI Error 0x80041017 – Invalid Query Using WBEMTest

During my free time, I do provide assistance to the community. Sometimes via forums, sometimes by giving a free session to local user group related to SQL Server. In this blog, I would share the steps to fox WMI error 0x80041017, Invalid Query.

In one of the forum posts, there was an issue related to WMI query. I asked to use WBEMTest utility to verify if WMI is working correctly on the server. Here were the steps I shared with him.

  1. From the Start menu, click Run, and then enter WBEMtest.
  2. The WBEMtest.exe dialog appears. Click Connect.
  3. In the first text field, type the WMI Provider for Computer Management namespace: root\cimv2. Click Connect.
  4. Click Query. Type a query that returns the current services running on the local computer:

Select * from Win32_Service.

  1. Click Apply.

When he performed this test, it gave an error:

Number: 0x80041017
Facility: WMI
Description: Invalid query

This means WMI for Windows is broken. I search and found below script which can help in fixing such error.

WORKAROUND/SOLUTION

Copy below script to notepad and save it as .bat extension. Then, run it from a command prompt with admin right (Run As Administrator)

@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
sc config winmgmt start= auto
net start winmgmt
for /f %%s in (‘dir /s /b *.mof *.mfl’) do mofcomp %%s
cd c:\windows\system32
lodctr /R
cd c:\windows\sysWOW64
lodctr /R

Reboot the machine and test WMI. Following the outcome of the test

SQL SERVER - WMI Error 0x80041017 - Invalid Query Using WBEMTest wmi-invalid-query-01

Here is the output of the query after fixing the error

SQL SERVER - WMI Error 0x80041017 - Invalid Query Using WBEMTest wmi-invalid-query-02

Have you encountered such error? It took me a long time to find the right solution. Hopefully, this would help someone. Please comment if it helped you in fixing any WMI issue.

Reference: Pinal Dave (https://blog.SQLAuthority.com)

SQL Error Messages, SQL Scripts, SQL Server, WMI
Previous Post
SQL SERVER – Install Error – The Reporting Services Catalog Database File Exists. Select a Reporting Services files-only mode installation
Next Post
SQL SERVER – Error: 17300 – The Error is Printed in Terse Mode Because There was Error During Formatting

Related Posts

5 Comments. Leave new

  • Hi, i am looking for ssma for msaccess tools which using 32bit configuration since i used winxp . unfortunately the officile website of microsoft stop publishinf theses old version of this tools. I will be very gratefull if you can post in your website the version ssma_for_Access5.3 wich support 32bit ( you can send me this version at my address mail) Thank you very much

    Reply
  • You’re tips and tools have truly been life savers for me Mr. Dave. Thank you !!

    Reply
  • Years after you wrote it, your post has been key for me to solve an issue.
    In my case, “Select * from Win32_Service” was running ok in my machine, but “SELECT * FROM Win32_PerfFormattedData_PerfOS_Memory” was giving the same error 0x80041017.
    Your script and a reboot solved the problem!
    Thanks again!

    Reply
  • I know this is 5yrs old, but your post helped me fix an issue with WMI ‘Win32_PerfRawData_PerfOS_Processor’ that was giving me the same error. The script fixed the issue. Thanks!

    Reply

Leave a Reply