• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 4904
  • Last Modified:

Sysprep on Windows XP - clean up non-existent devices


My goal is to have a ghost image that can be restored to a PC with different hardware. Before bothering to test on *different* hardware, I tested sysprep with the *same* hardware first:

(1) used -bmsd to build the mass storage controller sections in sysprep.inf
(2) run sysprep -mini -activated -reboot
(3) Let the mini setup finish upon reboot

The system did come up successfully, but I noticed the boot process was *much* slower. After I logged on, I checked the "Non PnP drivers" in device manager. There were many orphan devices which were not present before sysprep - e.g.  abp480n5, adpu160m (God knows what they are).

In fact, before sysprep there were 32 non-PNP devices; afterwards there were 75 of them. Hence there ware 75-32 = 43 orphans.

I checked the doc and there was a -clean switch that "cleans up critical non-existent devices". I run sysprep with this switch but it appeared to do nothing. These orphans were still there.

My question: how do I remove these orphan devices? (manual one-by-one removal from device manager is not acceptable).

1 Solution
This should explain and solve your problem


Hardware devices not installed in Sysprep image

When you use the Microsoft System Preparation tool (Sysprep) to deploy a Sysprep image of Microsoft Windows XP to a computer, some devices may appear in Device Manager as not installed even when the driver for the device exists in the path that is set by the oempnpdriverspath entry in the Sysprep.inf.

If you double-click on a device in Device Manager, you receive the following error message in the Device status box on the General tab:

The drivers for this device are not installed. (Code 28)
Additionally, a yellow exclamation mark appears next to the device when you view it in Device Manager.
This problem occurs when you create a Sysprep image on a computer and then deploy that image to a computer that has the same type of hardware. Any devices that do not have their drivers installed will remain in this state after the deployment of the Sysprep image. The minisetup program that is used by Sysprep does not perform a full Plug and Play re-enumeration of all devices.
Before you run Sysprep to prepare a computer for duplication, remove any devices in device manager that are set to Code 28. To remove these devices, follow these steps:
Click Start, and then click Control Panel.
Double-click Administrative Tools.
Double-click Computer Management.
Click Device Manager.
Locate any device that has a yellow exclamation mark next to it.
Verify that the device status for the device has the error message that is listed in the "Symptoms" section of this article. To do so:
Right-click the device icon.
Click Properties.
The Device status box lists the error message:

The drivers for this device are not installed. (Code 28)
Right-click the device icon, click Uninstall and then click OK.
Repeat steps 5 through 7 for each device that has the Code 28 error message.
GatingAuthor Commented:
My situation is entirely different from the one suggested by braincassin.

His situation: After sysprep, some devices have "code 28" (yellow exclamation mark) in device manager.

My situation: After sysprep, no devices had "code 28" error - everything is fine. The only problem was I got *EXTRA* Non plug-and-play devices installed. I saw these devices by choosing "Show Hidden Devices" in the device manager's menu.

At the risk of being too involved, probably I should supply more details:

1. Before sysprep, my Non PNP section in the device manager was very lean: it only contained "virtual" devices. By "virtual" I mean devices that did not correspond to real hardware. e.g. TCP/IP protocol driver, "sygate for NT, wg3n" (installed by sygate firewall), etc.

2. After sysprep, my Non PNP section got extra devices. Most of them corresponded to REAL hardware. For example,  ALI AGP Bus filter, AHA154x (probably some kind of SCSI controller), etc. THey did not exist before sysprep was used.

3. I am confused because the device manager reported these devices were "working properly". I was very sure they were physically not present in my PC. How could they "work properly"?

4. After I tediously removed them one by one from device manager, they came back on the next reboot!

5. My boot time were also increased by 30 seconds. I strongly suspected these extra devices were the cause.

Hope these help.
I have been down this path, and the decision we ,mmadfe was to leave all the drivers as it made the build esaier to support remotely, and if a driver gets corrupted, the driver files are already in place. XP eventually learns to ignore unneeded devices (which is why it boots quicker than W2K)
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

GatingAuthor Commented:
Hi rhrowson. I think having a copy of driver *files* in my hard disk is one thing; but having *devices* showing up in the device manager is another, especially when it adversely affects the boot time.

You see, having these driver *files* does not affect my boot time. However, having a *device* in device manager *DOES*, because the drivers must be loaded. Moreover, these are orphan devices (as I said before, my PC did not have "AHA154x", "ALI AGP BUS filter etc", "cpqarray", etc), therefore the boot process spent a lot of time in loading drivers and wait for timeout. *THIS* is the problem.
I'll have a look at my master image after deployment and see what it does. I have never noticed this behaviour, but I may have missed it.
GatingAuthor Commented:
OK I will answer my own question. I found the answer by experiments and reading the docs.

"sysprep -bmsd" populates sysprep.inf with entries, each of which corresponds to a mass storage controller found in the Machine.inf, Scsi.inf, Pnpscsi.inf, and Mshdc.inf. After that, when you use sysprep normally (without -bmsd switch), all such devices will be created in device manager, so that the next reboot will load *all* such drivers.

In theory, when this next reboot finishes, the "unused" drivers should be automatically cleanup. In practice, they are not. This is why I saw the orphan devices. To clear them, I have to use "sysprep -clean". The best way is to create C:\sysprep\i386\$OEM$ folder. Put there a cmdlines.txt file that reads

"C:\sysprep\sysprep -clean"

Then in the sysprep.inf file, put the line in the [Unattended] section:

This will make sure the orphan files to deleted.

One thing I discovered was that sysprep appended a section named "[SysprepCleanup]" to my sysprep.inf. This section contained all information about what devices should be removed. Provided this section was intact, "sysprep -clean" will do the cleanup for me.

But the tricky part is that C:\sysprep will be automatically deleted after completion. So when I login, I will see no c:\sysprep folder. In particular, I see no sysprep.inf file, so the[SysprepCleanup] section is not there, and "sysprep -clean" has no effect. I must cleanup *while* the sysprep.inf file is still there. This is why I choose to put the command in cmdlines.txt file.

As for the slow boot time, it turned out it was unrelated to these orphan devices. My system had Intel 845 chipset and I was using Intel Application Accelerator. Somehow the sysprep process messed up with the drivers installed by IAA, without warnings shown in the device manager.  I reinstalled it and the boot time was normal again. As to why this occurred, I am still investigating. However I now consider my questions answered by myself.

Thanks for your help guys.

User resolved; closed, 50 points refunded.

Site Admin
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now