Microsoft has provided a handy tool for adding additional drivers into Windows Vista and WinPE 2.0 WIM files. This tool is called “PEIMG”, and it is included in the Windows AIK, available from www.microsoft.com/downloads. Unfortunately, PEIMG does not have a recursive function, so if you want to add all of the drivers in a complex driver store (e.g. all of the drivers in a BDD Distribution Share), you need to do some scripting.
Fortunately, not much scripting is required… FOR comes to the rescue again!
for /R . %i in (*.inf) do peimg /inf=”%i” e:winpe_x86mountWindows
In this case, we are using “/R” to tell “FOR” that we want it to recurse though the given directory path (in this example, “.”) setting the variable “%i” to be equal to each “inf” file that it finds. On each pass we run “peimg /inf=”, injecting our variable as the inf file to inject.
All of this assumes that you have already mounted the target WIM file into the directory e:winpe_x86mountWindows.
We could fairly easily automate the whole winpe build process by stringing together these commands:
- imagex /mountrw <WIM file> <WIM Index> <mount directory>
- for /R .net %i in (*.inf) do peimg /inf=”%i” <mountDirectory>windows
- for /R .hdc %i in (*.inf) do peimg /inf=”%i” <mountDirectory>windows
- for /R .system %i in (*.inf) do peimg /inf=”%i” <mountDirectory>windows
- for /R .SCSIAdapter %i in (*.inf) do peimg /inf=”%i” <mountDirectory>windows
- imagex /unmount /commit <mountDirectory>
We could then use WDSUtil to import the image into a Windows DS server, convert it to a “discover” image. OSCDIMG from the Windows AIK to create automatically a WDS Discover ISO file.