Thursday, January 6, 2011

Fixing WMIDiag to run on Windows 7 and Windows Server 2008 R2

Hi everybody,

after having some trouble on my workstation with Acronis backup software, it seems that the root problem is somewhere inside WMI. Microsoft has created the WMIDiag tool to check all aspects of WMI and log the results in a large file. Unfortunately, it won't run "as is" on any OS newer than Vista SP1.
I found a hack though to enable the script to run on my Windows 7 Ultimate x64. In case you need the tool, you might find this helpful.

What you need

WMIDiag self-extracting archive (download here)
a text editor that is capable of showing line numbers, Notepad++ is a nice and free tool for this

Steps to enable newer OSes in the script

The WMIDiag main part is a very large VBScript that is pretty easy to modify. Extract the files to any folder and then open the file WMIDiag.vbs in the editor.
Move to line 147 to see the "known" operating systems. We need to insert two lines at line 167:

Const cWindows2008R2 = 262144
Const cWindows7 = 524288

Now we have defined internal IDs for Win2008R2 and Win7, and it's time to use them. Go to line 10776 (should read "Case Else"), and before that, insert the following block:

                Case "6.1" ' Windows 7
                     If RunTimeEnvironmentInfo.IsServerOS Then
                        GetOSVersion = cWindows2008R2
                        RunTimeEnvironmentInfo.OSBrandVersion = "2008 R2"
                        RunTimeEnvironmentInfo.ProductFullName = "Windows 2008 Server R2 - No service pack - " & RunTimeEnvironmentInfo.ProcessorArchitecture
                        RunTimeEnvironmentInfo.ProductShortName = RunTimeEnvironmentInfo.NTBuild & "_.SRV.RTM"
                           GetOSVersion = cWindows7
                        RunTimeEnvironmentInfo.OSBrandVersion = "Windows 7"
                        RunTimeEnvironmentInfo.ProductFullName = "Windows 7"
                        RunTimeEnvironmentInfo.ProductShortName = "VISTA.CLI"
                     End If

                     If RunTimeEnvironmentInfo.Is64 = False Then
                         RunTimeEnvironmentInfo.ProductShortName = RunTimeEnvironmentInfo.ProductShortName & ".32"
                        RunTimeEnvironmentInfo.ProductShortName = RunTimeEnvironmentInfo.ProductShortName & ".64"
                     End If

You should find the "Case Else" on line #10794 or #10795. You may insert blank lines to make the script look nicer, but there is no syntactical need for them. Now save the file.
This hack is not perfect - Windows 7 will be identified as "VISTA.CLI.32" or "VISTA.CLI.64" depending on the OS bitness, but I think this better not change because it might cause side-effects on the tests that are run. You will find this string in the report file and the Excel sheet that is created - never mind. You know from a lot of other indicators that it's actually not Vista.
Finally, move to line #17270 and change it as follows:

               Case cWindowsVistaRTM, cWindowsVistaSP1, cWindowsLonghornRTM, cWindows2008R2, cWindows7

Running the script

  • I'd recommend running the script in a shell instead of just double-clicking it as inside the shell you can see the script's progress. So, open the start menu, enter cmd in the search box and hold both Ctrl and Shift while clicking the Command Prompt entry shown in the results list. This will ensure that the command prompt is started with administrative privileges which you will have to confirm by a UAC prompt that opens right after you clicked.
  • Once the command prompt is open, enter Cscript.Exe /H:Cscript to make CScript your default script environment.
  • CD to the directory where you put the modified WMIDiag script
  • enter wmidiag to run the script

Good luck!

Well, now I can start digging the output for hints on what is actually wrong here :o|

2013-04-23 Version 2.1 Bugfix

Hi all,

after Microsoft updated the WMIDiag script to version 2.1 to include Windows 7 and 2008 R2 (well, about time now that Server 2012 and Windows 8 are out!), they included a bug again for our delight.
The structure of the statistics CSV file that is rendered in the TEMP directory by default is missing two columns. Therefore, the Excel output will not be okay once you imported the CSV file into it.

I think I found the missing columns. In Excel, it is the columns AD and AE. The CSV file is missing them, so everything right to the column AC is shifted left by two columns.
There are two ways to fix this:

  • modify the Excel sheet and remove the columns highlighted before importing the CSV
  • importing the file and then shifting everything in the line to which you imported from AD:CM two columns to the right

Shifting can be done easiest by selecting the range from AD thru CM, then using the clipboard to mark the selection as to-be-cut (with Ctrl-X), then placing the cursor into the column AT and then pasting (Ctrl-V). Please be sure to mark the cells of only the row you importeed, not the entire table with column headers etc.
It's a dirty hack, I agree, and it won't bring you back the information of how the WMI repository size changed in relation to before the script was run. Sorry, but I'll look for a fix.

Have fun!

2013-04-24 Version 2.1 Final Bugfix

Guys, I figured it out! There is an inactive line of code that should obviously be active. This circumstance causes the disk space measurements to take place only after the WMIDiag process, not before, even though these two additional values are expected in the Excel sheet

The problem is in line #1317 of the WMIDiag.vbs file. You can easily spot it by searching for "BEFORE" (with the quotation marks and in capital letters) with any editor. The first matching line is this one:

    ' boolRC = CheckWMIRepositoryFiles (objLOGFileHandle, "BEFORE")

To activate the line, remove the apostrophe character ( ' ) before boolRC. Please do this only if the line reads exactly like what is shown above. There are more lines matching the search expression, so be sure to hit only the first one of them.
The structure of the CSV output then matches the XLS columns perfectly again :)

You can get the fix from here (it is a ZIP archive containing all files of the original WMIDiag.exe, except for the fixed .vbs file)

Hope I could help some of you.

2013-06-12 Version Adjusted for Windows 8 + 2012

Based on the VBS script from 2013-04-24 (see above), I have added OS version constants and code to identify Windows 8 and Windows Server 2012, however I don't have any Windows Server 2012 installation here, so I could not properly test that.
For Windows 8, a whole lot of errors are logged in the C:\Windows\WBEM area. Don't know if that is only my system (it's a virtual machine I set up when the first free beta of Windows 8 was released).
Please check it out and let me know if you feel anything is wrong about it.

Get your ZIP here


2014-06-30 Version Adjusted for Windows 8.1

Based on the VBS script from 2013-06-12 (see above), I have added OS version constants and code to identify Windows 8.1. Internally it has version "6.3".
SP1 recognition has been added, too, although it is not clear at this time whether it will work properly. Likewise, it is still unknown when and if Windows 2012 Server will switch its version to 6.3. I think that is likely to happen if there will ever be a 2012 R2 edition. The VBS script will not recognize 6.3 server products for now however because there are too many uncertainties. I hope that is okay for all of you.
Thanks to Chris for notifying me about the 8.1 problems :)

Get your updated ZIP here



  1. Good god, dude, you are a lifesaver.

    I am going to link this to a Spiceworks (IT management software that uses WMI) message board (if it's not there already), so others can make use of this information.

  2. Have you run this on Server 2008 R2 SP1?

  3. No, all of this happened on Windows 7 and before SP1. Maybe the script needs another update for working with SP1.
    Unfortunately I don't have the time right now to try. I'm coming back later with results.


  4. Hi there

    I'm having trouble at "line #17270"

    Do I remove whats there (which starts with "arrayWMIDCOMDataList = Array") or copy in before that?


  5. Hi Darren,

    sorry, the line numbers are a bad guide here. No lines need to be replaced or deleted, we are just inserting. The line that needs to be changed in the last part (where you had trouble) is actually some lines above the one you mentioned. In the delivery version of the script, the line reads:

    Case cWindowsVistaRTM, cWindowsVistaSP1, cWindowsLonghornRTM

    We need to add two values (the two we added in the header area of the script, see early in chapter "steps to enable..."), so the line will read:

    Case cWindowsVistaRTM, cWindowsVistaSP1, cWindowsLonghornRTM, cWindows2008R2, cWindows7

    That's all. Let me know if this worked out for you. I hope it does.

    Best regards, and have a nice weekend!

  6. Thank you, saved considerable time :)

  7. Hi, I did try this on my Windows 7 environment, but I'm getting an error 'Unsupported Windows version - 32-bit (7601)' in the log?

  8. new version 2.1 which supports Windows 7 + Server 2008 R2

  9. With the updated version 2.1 comes an outdated Excel files where the Data tab does not match the Statistic file input... Any updated version available?

    1. Hi, I have taken some time to look at it and added a paragraph about it. Hope it helps.

  10. Any idea on version that supports Windows 2012? or Windows 8?

  11. Verified that your version of the VBS works correctly for Windows Server Core 2012. Thank you for the fix.

  12. The VBS will not run properly on Windows 8.1 :-(

    1. Hi Chris, the updated version should work. Please try it. Thank you!

    2. I'm sorry, I should have stated that I was running the updated version. I get an 'Unsupported Windows version" error. I can post more information if you wish.

    3. Hi Chris, thank you, your help is appreciated. Please run "winver" as a command, either press on the desktop or enter "winver" in the tiles screen. It opens a version info dialog where you can find the exaxt version number, something like "Microsoft Windows [Version 6.3.9600]". It may also contain details on the edition you are running so it might be a good idea to create a screenshot. Can you give me some more info on how you installed Windows? (did you install Windows 8 from scratch or upgrade from 7, which upgrades did you run)
      I will update the script right away as soon as I know more about your OS.

  13. Hello everyone, and sorry to all who tried to download the ZIP and failed because I did not share the file in public. I was not aware of it and apologize. The file is now shared for everyone who has the link (which you can find above).


Wenn du auf meinem Blog kommentierst, werden die von dir eingegebenen Formulardaten (und unter Umständen auch weitere personenbezogene Daten, wie z. B. deine IP-Adresse) an Google-Server übermittelt. Mehr Infos dazu findest du in meiner Datenschutzerklärung (Link einfügen) und in der Datenschutzerklärung von Google.