Vernalex.com
 
 M  E  N  U
 - Guides
 - Links
 - Tools
 - Themes
 




 
 

Tools: SysPrep Driver Scanner for Windows XP, 2003, Vista, 7, 2008, 8 and 2012


Table of Contents

 

Introduction to SPDrvScn

Drivers DirectoryThe purpose of this tool is to provide system administrators an easy when to roll out ever-changing Windows 2000, Windows XP, Windows Server 2003, Windows Vista, Windows 7, Windows Server 2008, Windows 8 and Windows Server 2012 images that use the Microsoft System Preparation Tool (SysPrep) by using this tool to enumerate your Windows drivers. You provide the tool with a base directory path and a extension type. Then when you tell it to run a scan it will search through that directory along with all subdirectories for files that match your extension. The recommend search is for a SysPrep driver store and with the extension set to inf so that it properly enumerates drivers. It will then only pick up directories that contain those matched files, in this example *.inf files, and then add those settings into the Windows registry so that when the SysPrep mini-setup runs it will search those directories. This program is meant to be run right before the SysPrep resealing is started, so it is suggest you add it to a batch file that has this program precede your sysprep.exe execution. The program also accepts command-line parameters to automate the process.

Please note that this program makes it so you don't need a OemPnPDriversPath line in your sysprep.inf file for XP and 2003 or a DriverPaths in your sysprep's XML file for Windows Vista, 7, 2008, 8 or 2012. In fact, all that line does is copy that data into the registry when it's run. This is a must for XP because the OemPnPDriversPath can only be 4096 bytes, whereas the registry value can be as large as a REG_EXPAND_SZ, so you can have much larger paths this way. In fact there is no direct limit to the size of the registry key, but the key itself can't contain more than 64,000 bytes when combined with the other data values. You should be aware though that the more paths you provide to SysPrep for the minisetup the longer the Plug and Play detection time because each device needs to scan these directories for relevant INF files. Don't let that worry you though because the INF files are small and unless you have thousands of directories the time should be fairly low. And for Windows Vista, 7, 2008, 8 and 2012 it works better than the XML method.

Also, please let me know if you have any questions, comments or suggestions for this program.

If you have any problems or questions about SysPrep itself then you should read my SysPrep Guide for 2000/2003/XP or SysPrep Guide for Windows Vista/7/8/2008/2012 that explain how to use the Microsoft System Preparation Tool and the problems associated with it.

Return to top.

Instructions for General Usage

SPDrvScnThe program can be run in one of two ways. The first way is from the GUI and the second is from the command-line. They can also be used in conjunction with each other. Please read these instructions first and then read the section on command-line parameters as they will build off these instructions.

When the application is run you will be presented with an empty list. It will default the extension to "inf" and the "Search Path" to "C:\drivers", but these can be changed from the available edit boxes. Typically you will not want to change the default extension since I gave the option for potential flexibility.

When you press the "1. Scan" button it will recurse through the "Search Path" for all files that match the extension type. If this is a directory that contains a lot of files and/or subdirectories then it could take a few moments. When the scan is completed then you should verify that the directories listed are ones that you want.

You can refine the list by using the "Add" button to create manual entries from other directories that are not provided. You should most likely add "c:\windows\inf", where "c:\windows" is your Windows folder. This folder is the default search folder for Plug and Play detection, so you should make sure it gets added along with your SysPrep drivers.

You can also remove items from the list, so if you notice that it added folders that aren't applicable to your operating system then you can manually remove them. An example would be a driver bundle that contains drivers for Windows 95, 98, Me, NT4, 2000 and XP when only you want the XP folder. The better way would be to delete the unneeded folders from the driver search path, but you can also just remove them from this list.

Device PathWhen you have properly verified the list you should then use the "2. Save" button. This will dump the listed items into the registry so that those paths will be scanned automatically when SysPrep starts its mini-setup. You can verify that the path is correct by using regedit and browsing to HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion and viewing the DevicePath value of type REG_EXPAND_SZ. It should contain all of the paths that are listed from the driver scanner in that string value.

When it's done scanning and you have saved the contents to the registry you can then exit the program by using the "3. Done" button (or from the system menu or from the upper corner x).

You should also read the section on the command-line to learn how to automate the use of this program.

Return to top.

 

Automation (Command-line Parameters / Arguments )

SPDrvScn from the Command PromptI designed the program so that it can be run from a batch file right before the computer is resealed by sysprep.exe. This means that you can completely automate its scan and that your driver database will be completely up-to-date everytime you SysPrep the computer. All that you need to do is keep the files in the driver path updated and this program will do all the manual work for you. I personally recommend that you place the SPDrvScn program executable (spdrvscn.exe) in your sysprep folder along with your other SysPrep files and add it to a batch file that executes spdrvscn.exe before sysprep.exe. I go into more detail about this later on in this section.

You can easily test the program to see if it's working from the command-line. You can run it without all of the command-line arguments except /q and it will scan the paths and import them into the registry, but it will present you with the dialogs. This way you can see the list it imports and any pop-up messages that you would normally get from the GUI.

The program syntax is:

spdrvscn [/folders ] [/scaninf] [/reg] [/def] [/buildpnp] [/scanpnp] [/exportpnp ] [/importpnp ] [/importinf] [/add ] [/windows ] [/exportreg ] [/duplicator ] [/manufacturer ] [/log ] [/q] [/?]

It should be noted that anything contained in brackets is optional and that all parameters are totally independant. If the path or text following a parameter contains a space then surround that path or text in "quotation marks" (like /p "c:\program files") or it will truncate the path or text.
Parameter
Description
/folders search_path
Provides the search path. If the path is a long path then surround it in quotes. This is the path that will be recursively searched for the files of the extension that you specify (or the default value). You can add multiple paths by delimiting with semicolons like "c:\drivers1;c:\drivers2;c:\drivers3".
/scaninf
Performs a scan for driver files (*.inf) from the provided search_path of folders from using /folders and all subdirectories.
/register
Saves the folders found from the /scaninf into the registry.
/default
Adds the default driver folder for Windows (%SystemRoot%\inf, which normally expands to c:\windows\inf).
/quiet
Does not show the GUI. Make sure when you use this that you have the parameters correct or you may end up accomplishing nothing.
/buildpnp
Looks through the seach_path as provided by /folders and generates a list of all plug and play codes found in those driver files. Normally you will run this before imaging a computer and export it to a file for quick importing and scanning during the SysPrep mini-setup.
/exportpnp export_path
Once you build the plug and play list with /buildpnp it is best to export the list to a file so it can be imported and scanned at a later point.
/importpnp import_path
Imports the plug and play that was previously exported with /exportpnp. After importing the list the best usage is to perform a /scanpnp.
/scanpnp
This will match currently installed hardware with the list generated from /buildpnp.
/importinf
Imports the current list of folders in the registry's device path.
/add driver_folders
Manually appends a semicolon delimited list of folders to the driver folder list.
/windows windows_folder
Specifies a separate Windows installation for setting /duplicator and /manufacturer information. By default they use in-memory HKLM\Software and HKLM\System.
/exportreg reg_path
Exports the folder list to a .reg file.
/duplicator text
Sets the registry duplicator string.
/manufacturer text
Sets the registry manufacturer string.
/log log_path
Outputs debug information to a log file.
/?
Displays help.


Examples:

  1. Most Typical (Automated)
    spdrvscn /folders "C:\drivers" /scaninf /default /register /quiet
    Starts a scan in c:\drivers and appends the default search folder (%SystemRoot%\inf). It then saves the settings to the registry and quits. Normally this is what you want to do before shutting down the computer. You can either run it before running sysprep.exe or you can use "sysprep /quit" and then run it afterwards. Personally I use it in a startup script during the mini-setup of SysPrep, but don't worry about that if you don't know what I mean.

  2. Typical, Manual INF Folder
    spdrvscn /folders "C:\drivers" /add "%SystemRoot%\inf" /register /quiet
    Starts a scan in c:\drivers and appends the folder %SystemRoot%\inf. It then saves the settings to the registry and quits. Normally you don't want to manually specify the INF folder. It is needed but it is easier to use /f instead.

  3. Multiple Search Folders
    spdrvscn /folders "C:\drivers_reference;c:\drivers_oem" /scaninf /default /add "c:\custom_driver" /register /quiet
    Starts a scan in c:\drivers_references, then adds those found in "C:\drivers_oem", appends the folder %SystemRoot%\inf and also appends c:\custom_driver. It then saves the settings to the registry and quits. Normally you will only need a single search path because you could have multiple subdirectories off a single driver folder. And normally you won't want to append multiple paths either.

  4. Multiple Appending Folders
    spdrvscn /folders "C:\drivers" /scaninf /add "c:\windows\inf;c:\windows\other_inf_folder" /register /quiet
    Starts a scan in c:\drivers, and then appends c:\windows\inf and c:\windows\other_inf_folder. The purpose of this example is just to show you that you can use semicolon delimited lists of paths.

  5. Standalone Program
    spdrvscn
    Just starts the program with the default settings. This is the same as running it from within Windows Explorer.

  6. Standalone Program, Changed Search Path
    spdrvscn /folders "c:\drivers"
    Just starts the program, but uses c:\drivers as the search path.

  7. Searches Path But Doesn't Save
    spdrvscn /folders "c:\drivers" /scaninf
    Runs the program and searches c:\drivers for folders with drivers but doesn't save the settings automatically.

  8. Help
    spdrvscn /?
    Displays the GUI for help. This is available within the program from the Help dropdown.

  9. Autosearch and Save
    spdrvscn /scaninf /register
    Searches the default location, which is c:\drivers, for drivers and then saves them but doesn't quit.

  10. Autosearch, Save and Quit
    spdrvscn /scaninf /register /quiet
    Searches the default location, which is c:\drivers, for drivers and then saves them but also automatically quits since it doesn't show the GUI.

  11. Duplicator
    spdrvscn /duplicator "Duplicated on 2000/01/01" /quiet
    Sets the duplicator string in HKLM\Setup and then quits.

  12. Manufacturer
    spdrvscn /manufacturer "Manufactured on 2000/01/01" /quiet
    Sets the manufacturer string in HKLM\Software and the oeminfo.ini and then quits.

  13. Export Reg
    spdrvscn /folders "c:\drivers" /scaninf /exportreg "c:\export.reg" /quiet
    Scans c:\drivers for drivers and then exports the files into a registry entry as c:\export.reg.

  14. Duplicator by Specifying Windows Folder
    spdrvscn /windows d:\windows /duplicator "Duplicated on 2000/01/01" /quiet
    Sets the duplicator string the HKLM portion of the d:\windows\system32\config\System hive.

  15. Very Advanced Usage
    spdrvscn.exe /folders c:\drivers /buildpnp /exportpnp c:\export.pnp /quiet
    Scans through driver folders and generates a list of all plug and play codes.

    sysprep.exe ... -quit
    You will need to run sysprep with -quit because you need to perform a step before the computer shuts down.

    reg.exe ADD HKLM\System\Setup /v CmdLine /t REG_SZ /d "c:\script.cmd"
    Change the HKLM\SYSTEM\Setup\CmdLine:REG_SZ path to a script that first runs spdrvscn as below.

    shutdown.exe /s
    Shutdown the computer.

    Image the Computer
    Take an image of the computer at this point with Ghost, ImageX or whatever way you prefer.

    spdrvscn.exe /importpnp c:\export.pnp /scanpnp /register /quiet
    During the SysPrep minisetup before driver detection occurs this should be run to detect the drivers much quicker because only a few folders are scanned.

Batch File Example:

The following script is an example of a batch file that could be used to SysPrep a computer. The example below though is not very complicated and a few things could be added to it. My personal batch file looks like this. But, it also makes use of other programs such as kill.exe (resource kit) and sync.exe (SysInternals). If you look at my batch file you will notice that I kill off all unneeded processes (including explorer.exe), stop all unneeded services, delete any temporary cache files that may have been created by the last SysPrep, terminate all SMB connections, rescan the driver structure with spdrvscn.exe, flush all files to disk and then execute the sysprep.exe file.

sysprep.bat

@ECHO OFF

ECHO SysPrep Driver Scanner with the default values supplied as arguments.
spdrvscn /folders c:\sysprep\drivers /scaninf /register /quiet

ECHO Command to automate SysPrep from the command-line. It is started with the start command so the command prompt window closes while SysPrep runs.
start sysprep -reseal -mini -quiet

Return to top.

 

Version History

2014/08/27: v3.0.0 released

This is a major update that includes a large rewrite of the user interface. The biggest change is that the scanner now supports exporting to a plug and play database for faster detection during SysPrep mini-setup, but for most people you can ignore this complicated functionality.

2013/10/15: v2.1.1 released

This is a small version update that makes UAC elevation work better.

2013/10/15: v2.1.0 released

After uploading to Download.com I was given the feedback from the reviewer that it would be nice if the program could open the registry so I added the ability to open the DevicePath, Manufacturer and Duplicator strings in the registry from the Help drop-down menu. The registry doesn't support loading paths as command-line parameters so I had to write my own interface to it so let me know if you have any issues with it but it seems to work well enough.

2013/10/14: v2.0.1 released

It has been a number of years since I have released a new version but I've completely rewritten the SysPrep Driver Scanner. Now it supports both 32-bit and 64-bit Windows in a single executable. I also have added better support for Windows Vista, Windows 7 and Windows 8, but it still works great for Windows XP. I cleaned up the interface a lot, added export to CSV/Tab/Reg, implemented support for offline registry processing and gave you the ability to use Windows environmental variables (such as %SystemRoot%).

2008/01/18: 64-bit version released

I have released an experimental test version of the 64-bit version of the SysPrep Driver Scanner. I have known for a while that my old version didn't run on 64-bit Windows, but there was little I could do about it because I don't have 64-bit Windows. Someone wrote in and explained the behavior of the 64-bit version so I realized I only needed to compile a new version. Anyhow, I can't test the 64-bit version so please if you have a 64-bit version let me know if it works properly.

2007/02/23: v1.3.2 released.

This release fixes a bug when you try to update the manufacturer information in the oeminfo.ini on a installation where the Windows directory is not C:\windows (such as Windows 2000). This behavior has now been fixed.

2006/12/29: v1.3.1 released.

This releases fixes two fairly minor bugs. The first is that sometimes the column widths were not being properly set, but they should be now. The other problem was that using /f and /i after using a /q switch did not quiet the append or import behaviors. This has now been fixed.

2006/06/01: v1.3.0 released.

Added the /f and /i command-line argument options. I also added a warning when you save the registry value in non-quiet mode but forgot to append the Windows' inf folder to the list. If you find these new features useful then you can thank Clark B. because he requested them. I also added a duplicate checker to keep the list cleaner and I added a few trivial features such as a clear button.

2006/03/21: v1.2.3 released.

Yet another small bug. In some circumstances I was making an odd write to the registry for the OEMDuplicatorString. It's fixed now.

2006/02/02: v1.2.2 released.

I found another small bug. When you put it into quiet mode it wasn't shushing the success messages. That's fixed now though.

2006/01/29: v1.2.1 released.

Oops, bugs!. In version 1.2 if you used command line parameters to use the duplicator or manufacturer string and also told it to scan the driver store then it would overwrite the settings you specified on the command line. Also, I changed the variable prefix from % to ~ so as not to interfere with batch file variables.

2006/01/29: v1.2 released.

I have once again recompiled the executable, this time with Visual C++ 7.1.3088 and once again merged it with the runtime. I have made the program a little more user friendly by providing interaction with the user that lets the user know when they did something right or wrong. I fixed a few bugs and added more error handling. But, the biggest changes were with the OEMDuplicatorString string and the Manufacturer string. You can now updates these manually or automatically with the program, and you can even insert some variables to make it useful. Read the instructions above for more information on how to use them.

2005/10/06: v1.1 released.

I recompiled the executable for Visual C++ 7 and merged it with the runtime. So, it's a tad bit larger (119kB) but now it should work in more diverse situations. I haven't added any new features yet though, but I will in the next release.

2005/05/15: v1.0 released.

In future revisions I plan on adding a way to blank the registry value and to accept environment strings. At the moment if you enter a %string% on the command-line or within the program as a base search path then it won't be able to scan the path. I'll also fix any bugs that people found, but it would be a large help if they're reproducible bugs.

Return to top.

 

Download

Program Name: SysPrep Driver Scanner
Download: Vernalex.com x32 / Vernalex.com x64 or Download.com
Current Version: 3.0.0 (final/release)
Release Date: 2014/08/27
Notes: The program has been tested on Windows XP, Windows Server 2003, Windows Vista, Windows 7, Windows Server 2008, Windows 8 and Windows Server 2012 (32bit and 64bit, except for Windows 2000). I would just recommend that you copy it into your sysprep folder and then create a batch file (see the previous section for details on that) and use that to kick off your sysprep procedure. Please let me know if you find this program useful, and also let me know if you have any features you would like to see in a newer version. If you find this program useful then please visit download.com and give the program a good ranking so that others will find it.

Return to top.