Windows PE 3.0 and the Missing WMI Class
Since I maintain the Windows XP Image for our lab machines, I was tasked with doing the same thing with Windows 7. When I rewrote our imaging tools last Spring, I created a WinPE 2.0 image that included the WMI package so that the imaging application could perform WMI queries in PE. I used WMI only to get basic information about the machine (Such as the Manufacturer, Model, Serial Number, and Disk Information).
While upgrading the WinPE image from 2.0 to 3.0 in anticipation of deploying Windows 7, I discovered that the Windows PE 3.0 base image (the same one that comes with the Windows AIK) was missing Win32_DiskPartition. I use this class to retrieve the number of partitions on the system disk so that I can make sure that each partitition (and its volume) has been assigned a drive letter so that I can search each drive for a preexisting configuration file. But why would Microsoft remove this class!? On a standard Windows 7 machine, the command “WMIC.EXE PARTITION” returned a list of partitions on the system, confirming that I wasn’t losing my mind. However, the command returned nothing when I tried it in Windows PE 3.0.
After lots of searching, I finally came across a post on Microsoft Technet where another developer ran into the same issue. Fortunately, he found a simple, but somewhat obscure, solution:
- On a fully-installed Windows 7 machine, copy the contents of C:\Windows\System32\wbem
- Mount the Windows PE 3.0 image and replace the contents of <mountdir>\Windows\System32\wbem with the wbem folder from the previous step
Using the Windows 7 wbem folder in your WinPE 3.0 image will make it several Megabytes larger, but at least you will be able to get to the missing WMI class(es) that you need!
Update 3/11/2010: After upgrading to the latest version of the Microsoft WAIK, I was unable to overwrite existing files in the WBEM folder (Access Denied). For some reason, the permissions are different on this folder now. Here is the workaround:
- To take ownership of the existing WBEM folder and files, run this command: TAKEOWN /F <mountdir>\windows\system32\wbem /A /R
- To grant administrators full control of the existing WBEM folder and files, run this command: ICACLS <mountdir>\windows\system32\wbem /grant Administrators:F /T
Once the permissions are updated, you will be able to overwrite files in the WBEM folder.
Update 3/18/2011: I was hoping that this issue would be resolved with the release of Windows 7 SPI and WinPE 3.1. Unfortunately, the problem still exists. However, I did some additional digging and found that, for me at least, there is only one file that I need to copy to the WinPE WIM fix Win32_DiskPartition: C:\Windows\Sysm32\wbem\en-US\cimwin32.dll.mui. Since the file doesn’t exist already in a fresh WinPE WIM, should shouldn’t have to deal with the ownership and permission issues mentioned above.
![[del.icio.us]](http://iboyd.net/wp-content/plugins/bookmarkify/delicious.png)
![[Digg]](http://iboyd.net/wp-content/plugins/bookmarkify/digg.png)
![[Facebook]](http://iboyd.net/wp-content/plugins/bookmarkify/facebook.png)
![[StumbleUpon]](http://iboyd.net/wp-content/plugins/bookmarkify/stumbleupon.png)
![[Twitter]](http://iboyd.net/wp-content/plugins/bookmarkify/twitter.png)
Hi,
I think the (better) solution to the missing WMI package is here:
https://www-secure.symantec.com/connect/articles/readyadventures-winpe
It’s a lengthy guide, but in short – you need to mount the WIM image, and add any packages you require, for example:
peimg /install=WinPE-WMI-Package c:\winpe_x86\mount\Windows
Thanks for the info Eric. I’m pretty sure the WMI package had already been installed. Many other WMI classes worked fine, it was just this one in particular that gave me trouble.
Thank you so much for posting this you have saved me diagnosing what i thought was a bug in my code!! I was getting an error code 80041006 which when i googled came up with memory related errors!
For what its worth to anyone trying to resovle this – you must inject the files before booting the image – copying once loaded didnt work for me even after running wpeinit.
Thanks again!
oh and i can confirm its missing files not missing packages.
Thanks for this tips.
After few searches, I installed winpe-wmi_en-us.cab package (with Waik 3.1) to my custom Pe with “dism” command.
I tested Win32_DiskPartition Wmi class with a VB script.
It’s work fine.
Hey guys, check this note. It solved my problem (Install all five packages, and WMIC working under PE 3.0).
http://www.msfn.org/board/topic/143622-how-to-install-wmic-in-winpe/
Thanks for help guys. I found the issue was you needed more packages installed than just wmi and scripting.
I ended up also install the following packages:
XML
MDAC
HTA
So I basically installed 5 packages into PE (I used PE 2.1)
I doubt all 3 of these were needed, but with them installed wmic works correctly! I’m too lazy to go back right now and figure out which of these 3 packages is actually needed, but I will eventually. But for now, if you install the following 5 packages total under PE2, then wmic.exe will finally work correctly:
wmi
scripting
XML
MDAC
HTA