SysPrep in Depth – Part 1 – Adding Drivers To Our Image PC

Preparing a PC to be Imaged with SysPrep

When trying to clone one computer to different sets of hardware using SysPrep there are a few steps you should take to help clean up the image computer and get it ready for multi hardware setup. I do realize that Vista does not use SysPrep anymore and this is “old news” but I know that it will still be useful to many people out there. Throughout this series I will talk about may parts to SysPrep, not just using it with different hardware, so if you are using SysPrep in your environment it might be a good thing to read over all of this once and see if you can apply any of it to your network.

So without any further ado here we go.

Lets explain how Windows XP and SysPrep interact and how to get them working properly together. Keep in mind that you need to pick and older PC as it is easier to move forward in technologies then it is backwards and that this method works in our scenario but might need further tweaking in your environment.

Adding Drivers to our Image

- Adding Default Windows Drivers

When Windows XP is first installed it has a large resource of drivers on the XP cd to choose from, but when you are SysPreping it no longer has access to these drivers. To resolve this issue we grab a Windows XP cd and copy the i386 folder to our SysPrep folder. Once finished you should have an i386 folder in your sysprep folder containing all the contents of the i386 folder from the CD.

To let SysPrep know that it now has a copy of the i386 directory as a resource we open up our sysprep.inf file and add an “InstallFilesPath” value under the [Unattended] section and set it value to our i386 directory. For my setup I have “InstallFilesPath=C:\sysprep\i386″.

- Folder Struture For New Drivers

How do we install drivers for other computers we have when the hardware is not in our base image PC? We don’t need to install them, SysPrep will take care of the new drivers for us as long as we provide the drivers to SysPrep. What we need to do is get a folder structure set up with each of our drivers we need on other computer models and even for the current model. We will need to have a folder for each driver we have and need to keep track of what driver is in what folder. There are many ways you could accomplish this and they would all work as long as you stay within the limits (see below) you can do this however you want.

For our example I will create a ‘drivers’ folder in the root of the system drive and within this folder create a folder for each driver type, number this folder, and then create another folder within this numbered folder for each driver. Within each folder including the ‘drivers’ folder create a txt file explaining what each of these numbered folders contains. In my current setup I have a txt file in the drivers folder that let me know folder 1 is video, 2 is network and so on. In the video folder I have another txt file that lets me know what driver is in folder 1, 2, 3 and so on.

This might be a little confusing to look at but there is a reason for this, the OemPnPDriversPath section of the sysprep.inf file can only contain 4096 bytesof data and depending on how many drivers you have you might need to keep the OemPnPDriversPath (see below) paths shorter. There is another way of telling SysPrep what folders to look at but you pick the method that works best for you. There is a very good reason to have each drive in a separate folder but I will go over this in-depth in a latter post, just remember you should have one and only one driver per folder in your final setup. (Picking up on my hint?)

-Finding Your Drivers And Getting Them In Your Folders

There are many ways of getting drivers for all your devices and just to keep this short I will not get to in-depth in this post on how to do this. If I have some requests for it I will post in-depth directions latter. I suggest you try downloading your drivers from the hardware manufacturer and extracting the files manually or try using DoubleDriver.

Once you have all these drivers downloaded or extracted we can start putting the in the folders we created earlier. Once they are all in our folders we can create our OemPnPDriversPath section in our sysprep.inf file. This OemPnPDriversPath value should be added to your [Unattended] section of sysprep.inf. This value lets SysPrep know each and every folder you look at during the “Detecting plug and play” section of SysPrep.

This needs to be in a format similar to this:

OemPnPDriversPath="Drivers\1\1;Drivers\1\10;Drivers\9\4;Drivers\9\5;Drivers\9\6;Drivers\intel"

This is a semicolon separated listing containing each folder that has a driver in it. If you are lazy like me you will find a nifty little tool called PNPPath.vbs that creates this path for you with very little configuration. :)

As I mentioned before there is a second way of doing this and it is with a registry key. This key is called DevicePath and is a Reg_Expand_SZ located at  ’HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion’ but yet again if you are lazy like me you will find a program that does this for you as well… Spdrvscn is a small and easy program that you can run to import all these folders into the registry and being as though this key has a 64,000 byte maximum you might decided to use this method over the sysprep.inf method.

Edit (4/16/08): One more important thing about the DevicePath key, make sure you have the right order in this key as sysprep starts with the files folder listed and moves down the list. I just ran into an issue where c:\windows\inf ended up as the first folder and that just blew the clone out of the water. If sysprep finds an old inf in the c:\windows\inf folder it will look for the driver in the c:\windows\driver cache or one of a few other defaults it could pick and will not look at your driver folders. This can cause issues when you have an (an, this that proper?) usb only computer, and the network card is found before the usb devices. When the computer finds the network card and old inf it then prompts for the driver, and since you don’t have a mouse or keyboard this ends up just being a mean trick.

 

Whether you use sysprep.inf or the registry to let SysPrep know where your drivers are remember that you will need to update these values each time you add a new driver.

- Cleanup Cached Drivers In Your Drivers Folder

Before we finish up with our new drivers we need to clean up any drivers that have been cached by a driver search from Windows. When ever Windows searches a folder for divers it creates an infcache.1 file as a sort of index to let it know where drivers are on the next search. These infcache.1 files and can be delete without harm as long as long as they are in this ‘drivers’ directory and you have not installed hardware from the drivers within these folders.

Running a simple command line is the quickest and easiest way to delete all the infcache.1 files in these driver folders. (replace ‘c:\Drivers’ with you path if it varies)

del /s /q c:\Drivers\infcache.1 1>nul 2>nul

Now that we have all our drivers ready and cleaned up we can continue on.

Till next time. :)

19 Responses to “SysPrep in Depth – Part 1 – Adding Drivers To Our Image PC”

  1. SysPrep in Depth - Part 4 - Cleaning Up Unneeded Drivers « David Remy’s Blog Says:

    [...] sure you have created a drivers folder and let SysPrep know where these drivers are. Please see my SysPrep in Depth – Part 1 – Adding Drivers to our Image PC for more directions on how to do [...]

  2. mike Says:

    hi
    if i use the reg method for the driver search do i leave the OemPnPDriversPath out of the sysprep inf.

    thanks
    mike

  3. David Remy Says:

    Leaving the OemOnODriversPath in the sysprep.inf is optional if using the DevicePath registry key. If you use both and you have identical paths it would be redundant but not harmful. I normally end up using both the inf and the registry just to make sure I have all our driver paths included since we have 150+ some drivers. I hope this helps you out in your sysprep adventures.

  4. Max Says:

    Hey,
    Is there an easy way to get all the drivers you need from each different set of hardware? When I go to the manufacturer’s website, most drivers are setup.exe.

    Any help would be appreciated.

    Thanks,
    Max

  5. David Remy Says:

    There are a few ways and I hope to make another post going into more depth on this soon. Here are a few quick ways you might want to try. Download 7-zip and get it installed the then right click on those exe’s you are downloading and under the 7-zip menu try to extract the files. This doesn’t always work but can catch those pesky exe’s. If you have the ability to install the hardware and the drivers on a computer another way to accomplish this is using the DoubleDriver program I mentioned in the post. DoubleDriver doesn’t get all drivers (ie newer ATI Radeon driver) but will catch 90% of your drives as long as both the hardware and drivers are installed. Keep an eye out for a new post to go into way more depth. Thanks

  6. Yasir Says:

    This is great posting and very helpful in understanding “sysprep”. Please post the details of how to get the drivers for diffrent hardwares. I am stuck at that point and cant find any good ref on internet that can help me solve this problem.

    Thanks,

  7. Kevin Says:

    To capture the drivers you need a driver capture program like WinGhost.
    I don’t understand why it is benificial to delete the infcache.1 files before capturing the image. What does that effect, and how does leaving them cause problems?

  8. Kyle Says:

    So I take it that the post-sysprep PNP session does not recursively search all sub dirs of the folder specified by sysprep.inf’s OemPnPDriversPath (as I would have thought it does)? Is there any way to achieve this versus maintaining both the actual WIMs drivers folder AND the sysprep.inf’s OemPnPDriversPath value?

  9. David Remy Says:

    Yasir, I have posted directions for this here: http://remyservices.wordpress.com/2007/10/26/sysprep-in-depth-part-7-obtaining-your-drivers/
    I hope this helps you out.

  10. David Remy Says:

    Keven,
    The infcache.1 file is a drive file that Windows has copied. The issue with this file is that it is a generic name and Windows will try installing these drivers before any other drivers. Many times this will not cause and issue, especially when syspreping between the same hardware, but when going cross platform and cause issues. If you have a driver in a folder that contains a infcache.1 file and is for both AMD and Intel drivers you will run into issues right away. Say you made the clone on an AMD computer and left the infcache.1 file in this driver folder, when the Intel computer looks for the driver it will find the .inf says that this folder contains the drivers for the hardware and install based of the cached infcache.1 file. This will not be an issue very often but can cause drivers to install wrong versions, old versions and legacy versions without checking for the correct version. I have always found deleting the infcache.1 file helps clean up your drivers to verify you get clean and fresh drivers the first time around.

  11. David Remy Says:

    Kyle,
    I agree with you, I wish you could just tell sysprep a root directory and let it do its search recursively but that is not how it works for some reason. Maintaining ether the OemPnPDriversPath or the registry setting is the only way of getting sysprep to look in other folders. You don’t have to maintain both paths but as long as you maintain one you will be fine, just remember that the OemPnPDriversPath is limited in length more so then the registry setting.

  12. Glenn Deans Says:

    fwiw, I prefer the registry method b/c it remains behind after sysprep/mini-setup. I also drop my driver folder(s) under %WinDir% so the users are less likely to delete them.

    I’ve never had any infcache.1 files created so I’ve never run into any issues there. Something to watch out for in the future. Thanks!

  13. David Remy Says:

    Not that I don’t agree with you Glenn, you bring up a great point, but for complicated reasoning we delete the drivers folder after sysprep finishes so the registry method then points to a non existing folder, thus making it a little less useful.

    The method all depends on what you need and how you want to use it I guess but ether way works great if you just take the time to understand it.

    Throwing the drivers into the %windir% is a great idea, never thought of that but it makes since to keep your drivers around if you can and then to hide them in the windows directory.

    The infcache.1 file is created if the windows driver search utility parses a folder with some drivers in it. Ever now and then I copy a driver onto a usb stick to take to a computer, after the computer installs the driver I have one of these infcache.1 files. They aren’t really a huge issue but they ‘can’ cause problems ’sometimes’ and I always just play it safe.

    Thanks for even more great ideas!

  14. Glenn Deans Says:

    It just depends on what the needs of the environment are I guess. I keep my drivers around b/c we have a custom service running for periodic updates, similar to Windows Update, and we can update drivers as well. I think the Perl saying goes for imaging as well – There’s More Than One Way to Do It!

  15. TekMason Says:

    In regards to Kyle’s question about recursively searching from a root directory. It just seems silly that MS wouldn’t build in this feature!
    Doesn’t Windows search recursively for drivers on removable media like a CD?
    If so, might there be a way to fake Windows into thinking that the root folder is a removable media?
    I guess worst case you might be able create a driver library on CD and point it there?

    TekMason

  16. antonio Says:

    Hi I’m unable to get sysprep XP to load the either the dell or nvidia sata drvier on the Dell 740. I’m using the vernalex drive scanner which works pretty well picking up most drivers but not this one. I’ve also tried using hte Build Mass storage section, but to no avail either.

    Any thoughts anyone?

  17. Joel Seber Says:

    David,

    I have a solution to the Dell Nvidia drivers problem (in fact, for any mass storage driver needs that are different from users’ norms) that I would like to share. In my case, I have new Dell XPS 720 systems that I wanted to clone XP system images to from Dell Dimension systems. Due to the Nvidia mass storage drivers, my images would not work, even with the all the guidance from this great blog on Sysprep. After much cloning and testing, I hit on the idea of installing a Promise card (that may not be necessary but I wanted to isolate the Nvidia motherboard drivers entirely), attaching a standard IDE drive, and loading the image there. Once I got a bootable system, I just ran the Nvidia nforce driver install. The drivers installed just fine as they saw the Nvidia SATA device on the running system. Once that was stable, I cloned the system from the IDE drive and loaded it onto the SATA drive that came with the computer. The computer booted first time, no hassles.

    I hope this will help others to get their systems up faster. This method should work with other systems and chipsets as well.

  18. Virtualisation, VMWare, SysPrep - not as easy as it seems | JB Enterprises — Johan Bezem Says:

    [...] going through much of the necessary details using SysPrep. Thanks, David! SysPrep in Depth – Part 1 – Adding Drivers To Our Image PC SysPrep in Depth – Part 2 – Verifying SysPrep And Driver File Permissions SysPrep in Depth – Part 3 [...]

  19. Thomas Roes Says:

    Great blog. Very helpfull. One question.

    Consider the following scenario:

    We have a working sysprepped image for all our hardware. With the last order, we receive a PC with a new type of hardware.

    I could make a new sysprepped image with the new drivers, but I would like to use a shortcut!

    I could add the driver to the sysprepped image in a new folder, but that would not work because this new path is not in met oempnpdriverpath parameter.

    What I do now is search a driver that does not conflict a new driver, not one filename may match! Then I copy the new driver together with a not-matching driver in the same folder.

    This works, but it starts getting a mess.

    Is there a way to make 20-30 extra folders for drivers that you don’t already have.

    Long ago I tried this, but sysprep doesn’t like a folder in oempnpdriverpath that is empty.

    Could I fill all these folders with the smallest driver I can find so I can replace this smal driver when I need to add a new driver?

    Thanks for your opinion on this

    Thomas Roes


Leave a Reply