Experiments with Sysprep

With the Technician Computer at hand I’ve recently been familiarising myself with the Windows SIM tool and actually building the unattend.xml answer file – I must say I find it very exciting and am really getting stuck in!

I kept it simple to start off with – to completely automate the installation while generating a random computer name, enabling the built-in admin account and customizing the default user profile. With the groundwork done beforehand my first answer file, I can say with some satisfaction, worked without a hitch! 

Understanding configuration passes, reading TechNet articles, learning from other peoples experiences on various blogs and forums, etc – that’s my idea of groundwork. Hence I knew the steps required for the above, particularly customizing the default profile (set the copyprofile element to true in the answer file and delete all user accounts and user profiles except for the local admin account before running Sysprep).

When installing Windows 7 on my HPDC5800 it does not install my audio driver, also the Ethernet driver that it does install is outdated. This gave me the opportunity to experiment with the settings in the answer file and installing drivers as part of the unattended process.

Pointing to device drivers located locally or on a network share

I initially tried this method in the windowsPE pass (using the Microsoft-Windows-PnpCustomizationsWinPE component) but it threw up an error message when applying the settings, something about the Microsoft-Windows-Shell-Setup component in the Specialize pass – even though I made no changes in that pass and the answer file had validated all right.

I got this one working in the end with the Microsoft-Windows-PnpCustomizationsNonWinPE component under the auditSystem pass. With DriverPath entries in my answer file pointing to my locally stored drivers, the drivers were installed after generalizing the system and booting in audit mode (with the /audit command).

Once in audit mode (and confirmed the drivers installed ok) I ran Sysprep  again (with the /oobe command) but this time with a second answer file without the DriverPath entries.

UPDATE: To completely automate this I went back to the first answer file and added a Synchronous command (using WIndows SIM) in the auditUser pass to run sysprep again with the /oobe command and the second unattend.xml answer file.


Having gone through the Sysprep process a few times during my experiments I got fed up of Windows re-installing the driver for my USB drive each time I plugged it in after running Sysprep – generalizing the system removes drivers for all your devices as part of the Sysprep process.

I came across this setting in the answer file to retain the driver for my USB drive before Sysprep and generalizing the system (without the Audio and updated Ethernet driver).

Adding drivers to C:\Windows\inf

This is the simplest method I tried, requiring no special setting in the answer file. I simply copied my Audio and Ethernet drivers in a subfolder under C:\Windows\inf, ran Sysprep, rebooted and waited for Setup to finish its work. Sure enough, when I logged on my Audio and my (up-to-date) Ethernet drivers were installed all ready to go.

I can see this method is useful if building an image for multiple hardware – if you had say three to four different hardware then simply organise the drivers for each in subfolders and chuck ‘em in C:\Windows\inf. Setup will (should) search and find the right drivers for the corresponding hardware . I haven’t tried this myself but it’s definitely something that interests me!


I’m still working on that one – I’ve been distracted with odd jobs here and there, hence this post has been in the making for far too long and I just want to get it out there at this point.

This cmd file runs after setup completes and before the first log on – useful for post-imaging tasks. There are a few thing I’ve got lined up to take a look at – pnpUnattend, Pnputil, and also using WMIC to work out the computer model and install specific drivers for that computer only. I’ll update this post when I’m ready with something more to write.

UPDATE: To install drivers using pnpUnattend.exe I decided to skip SetupComplete.cmd but instead use a different method. Here’s what worked for me (in my first attempt!):

1) Copied the drivers to C:\MyDrivers

2) Created a .reg file to add a registry entry pointing to the path to the drivers 

3) Created a .cmd file to run the above .reg file and then run pnpUnattend.exe /L

4) Inserted a synchronous command in my answer file to run the above .cmd file in the Specialise pass

5) Run sysprep with the above answer file.

Having found out WMI doesn’t work in the Specalise pass, I can only think of getting it to work in the auditSystem pass but haven’t tried that yet. I might give it a shot some time in the future if I can borrow a Windows 7-capable PC from somewhere.

I haven’t had time to try PnPUtil.exe but I imagine it should be simple enough to add a synchronous command in the answer file to install the driver in the Specialise pass. 


2 thoughts on “Experiments with Sysprep

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s