Last Revised: 11/11/08

 

Since I was updating my web site, I decided to update these instructions and make them a bit clearer.

Whenever you see C:\WINDOWS: that can be substituted for C:\WINNT if you are using Windows 2000 and vice versa.

1. Install Windows 2000/XP fresh on a machine. Use the following directory structure for the driver downloads:

C:\install\driver\<make_of_pc_model_of_pc>\<device class>

Here are some examples:

This would be the directory structure for a PDS Infinity BR-2’s audio drivers:

C:\install\driver\pdsbr2\audio

This would be the directory structure for an Omnitech 8100’s chipset drivers:

C:\install\driver\otc8100\inf

Here is the key for the class of devices:

Audio = audio drivers
Inf = chipset drivers
NIC = network drivers
Video = video drivers
USB = usb drivers


3. All driver downloads are to be extracted and simplified. Do NOT use setup.exe or install.exe files that come with driver downloads. Have it so that ALL files (particularly the *.INF/*.SYS/*.DLL files) are in the base device class directory and ALL subdirectories are removed. We are going to have sysprep just search the base directory: subdirectories below the device class directory will NOT be searched by sysprep.

Examples:

Good:

C:\install\driver\otc8100\audio\some.inf
C:\install\driver\otc8100\audio\some.sys
C:\install\driver\otc8100\audio\some.dll


No subdirectories below audio
Correct OS drivers in the base directory

Bad:

C:\install\driver\otc8100\audio\lib\src\some\where\down\here\some.inf
C:\install\driver\otc8100\audio\win98


INF file nested several layers deep. Sysprep will never see the above INF file.
Subdirectories below audio

Tips on extracting drivers


Some companies “hide” all the setup files in an executable. This is especially true for Intel based IDE and chipset drivers. You can use the following example to extract out the files for Intel based drivers:

“Infinst_enu.exe –a –a –p C:\temp”

The setup will run as usually, however, instead of installing the files it will extract them out to C:\temp.

Added 11/11/08

While reading articles on the Internet how to hack my Hauppage 878 TV Tuner card with work with Windows Vista Media Center, I discovered that Winrar can open EXE files and uncompress the files within them! So if you can't figure out what switches you need to run to extract the INF files within an EXE, this might be another solution.

4. Since you will be installing drivers without setup.exe or install.exe executables it can be hard to determine what INF files from a driver set to use (a driver set though listed specifically for our PC device will usually have support for an array of devices). We can use a program called Everest to help us identify what INF file to use (and what exactly devices we have in the PC). Download the trial edition from www.lavalys.com (note: Everest will not work on a computer that is joined to a NT domain, but this should not be a problem for us). Get the zipped version and extract it to C:\temp on the image. Run it from the image. Expand the Devices tree and then click on Physical Devices. Everest uses its own internal database to identify devices and not the drivers in Windows.

You can then use this information to search the text within the INF files to pinpoint the correct set of drivers (Intel chipset drivers, as an example, usually have driver sets embedded for 4 different sets of chipsets. Therefore, it is important to pinpoint the exact set you need.)

5. After you install a driver you should verify that it is correctly installed and is digitally signed. There should not be any yellow exclamation marks or red X’s in the device manager.

6. After you have loaded all the drivers you should copy the driver directory structure to a network share for safe keeping. It’s now time to setup the sysprep part. I’m not going to go into setting up sysprep from the beginning since anyone setting up a Windows 2000/XP image has used it, but I will just specifically detail the points for having it get the right drivers for the mini-setup. The comments should help you figure out what is what. Here's a copy of the sysprep.inf I use.

[Unattended]
; Install drivers even if they are not signed by Microsoft
DriverSigningPolicy=Ignore
; Indicates that you want the cmdlines.txt file processed
OEMPreinstall=Yes
; Accept the EULA automatically
OEMSkipEula=Yes
; Extend NTFS partition if disk size is larger then image partition
ExtendOemPartition=1
; Set OEM driver path to correct place
OEMPnPDriversPath=install\driver\pdsbr2\nic;install\driver\pdsbr2\audio;install\driver\pdsbr2\video;; Overwrite existing installed drivers from the ones on the source disk
UpdateInstalledDrivers=Yes
; Points to Sysprep install files (used by cmdlines.txt)
InstallFilesPath="C:\sysprep"


The [SysprepMassStorage] section is very important. You need to tell Sysprep which IDE drivers to load at boot. Otherwise, you will probably get a STOP 0x7B before the mini-setup.

Finding the IDE Driver Used To Setup [SysprepMassStorage]


 Go to Device Manager. Right click on the IDE controller, go to Properties. Click on the Driver tab. Go to Update Driver. Hit Next. Pick "Search for a suitable driver for my device". Click Next. Check "Specify a location". Uncheck the rest, just click Next then OK. It will search all INF paths. If it comes up with C:\winnt\inf\oemX.inf, where X is a random number, delete that file and the PNF file. For example:

sysprep1

Delete all OEM0.* files, then click Back, then Next.


sysprep2

Point it to the correct directory. It will be of the format C:\install\driver\<mode_of_PC>\ide.

sysprep3

It will now identify the correct file it uses to install the device. Search C:\install\driver\br\ide\idechndr.inf for "82801DB". We find the following:

; ICH-4 - 82801DB
%PCI\VEN_8086&DEV_24CB.DeviceDesc%=IdeBusDr_Inst, PCI\VEN_8086&DEV_24CB&CC_01018A ; PCI Native Disabled
%PCI\VEN_8086&DEV_24CB.DeviceDesc%=IdeBusDr_Inst, PCI\VEN_8086&DEV_24CB&CC_01018F ; PCI Native Enabled
%PCI\VEN_8086&DEV_24CB.DeviceDesc%=IdeBusDr_Inst, PCI\VEN_8086&DEV_24CB


Change it to the following format for sysprep.inf:

; IDE chipset drivers for Infinity BR-2
PCI\VEN_8086&DEV_24CB=C:\install\driver\br2\ide\idechndr.inf

Repeat the process for all other IDE chipsets on other hardware and add them to sysprep.inf file.

Added 11/11/08

Note: you might need to specify a subsystem id as well. See this blog posting for more information. I only ran into this issue on recent Dell models such as the GX755 and T3400.

Oh, you can also use the Physical Devices tab of Everest if you want to skip all the steps with the Device Manager to identify the model of chipset. :)

Sysprep Having Trouble Finding Drivers For a Device?


Remove the unknown device from device manager. Start Procmon by Sysinternals. Run Add/Remove Hardware. What does it show? If it is looking at an INF file in “C:\winnt\inf” delete that file and try again.

If you still cannot find the drivers, do the following: locate the unknown device in the device manager.

 

sysprep4

Right click on the device, go to properties. Look at the location description. If we use the example below that is “PCI bus 2, device 6, function 2”.

sysprep5


Now load Everest. Click on Physical Devices. Look for “Bus 2, device 6, function 2.”

sysprep6

So it’s looking for drivers for an "O2Micro Multimedia Bay Accelerator". Get the drivers from the vendor’s site.

You may also have to “hack” the driver INF files. Here’s an example from the INF for the ATI video file for the HP N1000C laptop:

[SourceDisksNames.x86]
1 = %DiskId%,,,.\BX_07000

[SourceDisksFiles]
ati2dvag.dll=1
ati2evxx.exe=1
ati2mdxx.exe=1
ati2mtag.sys=1
ati3d1ag.dll=1
ati3d2ag.dll=1
ati3duag.dll=1
atiddc.dll=1
atiiiexx.dll=1
atioglxx.dll=1
atitvo32.dll=1


There are two ways of dealing with this: hack the INF file or work around it. I prefer “hacking” the INF file as it is consistent and a clean way doing things. The only downside is that Windows won’t treat it as a digitally signed driver anymore (even though it is). If we wanted to work around it we could extend the OEMPnpDriversPath to include the BX_07000 subdirectory. I think that is messy. Instead, I did this:

[SourceDisksFiles]
ati2dvag.dll
ati2evxx.exe
ati2mdxx.exe
ati2mtag.sys
ati3d1ag.dll
ati3d2ag.dll
ati3duag.dll
atiddc.dll
atiiiexx.dll
atioglxx.dll
atitvo32.dll


7. Create a Cmdlines.txt file with the following lines at the top of the file:

 

[Commands]
"C:\Sysprep\Sysprep -clean"


as the first item in the file to disable all of the mass storage controllers that were not installed because they were not present on the destination computer.

If this line is not added to Cmdlines.txt, the start-up process for the destination computers may be slowed down while the computers attempt to load each controller driver with each reboot.

Place the Cmdlines.txt file in an $OEM$ folder in the location specified in the Sysprep.inf file by the InstallFilesPath parameter. For example, if:

InstallFilesPath = "C:\sysprep"

you would then copy the Cmdlines.txt file into the C:\sysprep\$OEM$ folder.(Note: to make sure cmdlines.txt is executing make a file called test.cmd and put it in the $OEM$ folder. Then put “dir > C:\testme.txt” in the test.cmd file. Add “test.cmd” under the [Commands] section. If you see that testme.txt was created after the sysprep mini-setup cmdlines.txt is working as expected. You can then remove it from the script.)

8. Clean out the HKLM\Software\Microsoft\Windows\CurrentVersion\DevicePath key in the registry. Everytime you run sysprep it appends the path state in OEMPnPDriversPath in the sysprep.inf file to this registry key on the base image. This can make this key extremely long if you do not clean it out.

9. Run “cleanmgr” from a command prompt. Purge Internet cache history from Internet Explorer. Defrag image.

10. Copy the sysprep folder to the root of C:\. Run sysprep.exe. Do NOT use the –pnp option. Only use –pnp if you have legacy ISA devices in your computers.

11. Reboot PC. Run through all of the setup. Make sure sysprep can find all the drivers and
that drivers for all devices are correctly loaded. Reconcile all errors.

 

Cool Scripts for Sysprep

 

Example script removing keys from the autorun parts of the registry.  The key will consist of a name value and a data value.  The name value is the key you want to remove

 

Filename: autorun.reg

 

REGEDIT4
[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\Currentversion\Run]
"IgfxTray"=-
"HotKeysCmds"=-
"smapp"=-
"Matrox Powerdesk"=-
"ATIModeChange"=-

 

Example script that runs PCI32 (see Tech Files section for download location) to see if a modem is present. If we find a modem we assume we are imaging a laptop.  If it returns errorlevel 0 (i.e. it found a modem), run a script.  Otherwise, do nothing.

 

Filename: detect.cmd

 

@echo off
C:\install\temp\pci32 > C:\install\temp\dev.txt
C:\winnt\system32\find /i "modem" C:\install\temp\dev.txt >NUL

if errorlevel 1 echo "Not a laptop, do nothing"
if not errorlevel 1 "C:\install\temp\profcopy.cmd"

 

Cleans out the devicepath key as sysprep will append to it each time you run sysprep on an image

 

Filename: devclean.reg

 

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion]
"DevicePath"=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,\
00,74,00,25,00,5c,00,69,00,6e,00,66,00,00,00

 

Disables number lock key for current user and system profile (i.e. profile that the system uses when no one is logged in)

 

Filename: numlockd.reg

 

Windows Registry Editor Version 5.00

[HKEY_USERS\.DEFAULT\Control Panel\Keyboard]
"InitialKeyboardIndicators"="0"
"KeyboardDelay"="1"
"KeyboardSpeed"="31"

[HKEY_CURRENT_USER\Control Panel\Keyboard]
"InitialKeyboardIndicators"="0"
"KeyboardDelay"="1"
"KeyboardSpeed"="31"   

 

Enables number lock key for current user and system profile (i.e. profile that the system uses when no one is logged in)

 

Filename: numlocke.reg

 

Windows Registry Editor Version 5.00
[HKEY_USERS\.DEFAULT\Control Panel\Keyboard]
"InitialKeyboardIndicators"="2"
"KeyboardDelay"="1"
"KeyboardSpeed"="31"

[HKEY_CURRENT_USER\Control Panel\Keyboard]
"InitialKeyboardIndicators"="2"
"KeyboardDelay"="1"
"KeyboardSpeed"="31"

 

Example script that copies over a default user profile with the number lock disabled in the profile.  Sets video resolution to 1024x768 (setres available here).

 

Filename: profcopy.cmd

C:\winnt\system32\xcopy C:\install\temp\laptop\profiles "C:\documents and settings" /o /f /e /y /h /r
C:\winnt\regedit /s "C:\install\temp\numlockd.reg"
C:\install\temp\setres.exe 1024 768 32 75

 

Cool Links for Sysprep and Unattended Windows Installation Stuff

 

A Tale of Two HALs (cached copy from jnux.net)
Microsoft Software Forum Network (check the unattended and drivers subforums!)

Make a Generic WDS image for Windows XP

Quick and Dirty ImageX (free replacement for Norton Ghost)

Very Nice Sysprep Guide with Video Tutorials!

 

Updates

 

7/30/05: I wrote an update to this article which includes talk on Windows XP on my blog here.

 

7/10/06: My instructions force a specific HAL across multiple hardware types which is not supported by Microsoft.  There are two other solutions that have been posted by technicians on microsoft.public.windowsxp.setup_deployment which do support on-the-fly HAL detection and change:

 

Johan Arwidmark's script for Windows PE - picks the right HAL based on the hardware you are deploying the image to.

 

James Tsay's script for Windows 2000/XP - picks the right HAL based on the hardware you are deploying the image to. Uses "hacked" mysysprep.exe in place of sysprep.exe to update sysprep.inf on-the-fly

 

3/3/07: This blog entry describes how to change Windows XP's HAL within the Device Manager and how to replace the HAL on a non-booting image