Tools: SysPrep Driver Scanner
Table of Contents
Introduction to SPDrvScn
The purpose of this tool is to provide system administrators an easy when to roll out ever-changing Windows 2000 and Windows XP 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. In fact, all that line does is copy that data into the registry when it's run. This is a great benefit 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.
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 that explains how to use the Microsoft System Preparation Tool and the problems associated with it.
Return to top.
Instructions for General Usage
The 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:\sysprep\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.
When 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 )
I 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.exe [/p [search_path]] [/e [extension]] [/d [append_path]] [/o [duplicator_text]] [/m [manufacturer_text]] [/a] [/s] [/q] [/f] [/i] [/?]
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.
Provides the search path. If the path is a long path then surround it in quotes. This is the path that will be recursivelysearched for the files of the extension that you specify (or the default value).
Supplies the file extension that will be used to scan. This should only be the extension and shouldn't contain and wildcards and it should not contain the leading dot.
NOTE: I provide this switch so the program is more flexible; however, I can't think of any reason not to leave this set to the default value of INF.
This is a path that you can supply explicitly. It is recommend that you add your Windows' INF folder (by default it is c:\windows\inf in XP). This can be a semicolon delimited list too. Also, if it contains long file names then include the entire "append_path" in quotes. It should be noted that this folder will not be scanned for validity, so be sure that you enter it correctly.
||The purpose of this parameter is to append the default search path. This should almost always be added or you should manually add your inf folder. This uses the %systemroot%\inf so it will work on any drive letter and Windows folder name. This is also the default for the registry value that my program changes.
||This will import the current DevicePath (from the registry) into the path lists. This is useful if you just want to append additional paths. This is safe though because all duplicate entries will be removed.
||This parameter will take the text you provide and it will update the manufacturer information in the oeminfo.ini (typically c:\windows\system32\oeminfo.ini) so that this text will appear in the "Computer:" section of the system properties dialog. I provided this feature because it is useful to know which version of your image is on a computer, and in this way you could post that information in a place that you can easily look it up when you use a computer that has your image. If this text contains a space then surround it in quotes ("manufacturer"). Also, to make this actually useful you can use variables in this text string. These are ~hour, ~minute, ~second, ~day, ~month, ~year, and ~weekday. To better understand this see the examples where /m is used. If this entry is not provided then it won't do anything, and if you want to blank this entry follow it with double quotes "".
||This parameter will take the text you provide and it will update the OEMDuplicatorInfo information in the registry (HKLM\System\Setup\OEMDuplicatorString). I provided this feature because it is useful to know which version of your image is on a computer, and in this way you could post that information in a place that you can easily look it up when you use a computer that has your image. If this text contains a space then surround it in quotes ("duplicator"). This registry entry is usually filled-in by SysPrep, but if you use it here instead you can make this actually useful since you can use variables in this text string. These are ~hour, ~minute, ~second, ~day, ~month, ~year, and ~weekday. It should be noted that this registry complements other registry values, the most interesting being the CloneTag entry that shows the time when the computer executed the mini-setup. To better understand this see the examples where /d is used. If this entry is not provided then it won't do anything, and if you want to blank this entry follow it with double quotes "".
Choose to auto scan the search_path. This will auto scan the default path if you don't provide a path (c:\sysprep\drivers) and it will use the default extension (inf) if you don't provide an extension.
Saves the scan information automatically on startup. You will most likely want to use /a along with this or at least use the /d option, otherwise it won't do anything.
Runs in quiet mode, which basically means it quits before showing the GUI. To be useful this should be combined with /a /s, otherwise it won't serve any purpose. It should also be noted that /q will not return any errors, so if you do something silly such as run it with /s without /a then it won't tell you that it did nothing.
This returns information on the command-line parameters. You can also see the available command-line parameters from the about box (either in the system menu or on the main page's about button).
1. spdrvscn /p c:\sysprep\drivers /e inf /d c:\windows\inf /a /s /q
Scan the "c:\sysprep\drivers" directory and subdirectories for *.inf files then append the "c:\windows\inf" folder. It then will save the settings and quit.
2. spdrvscn /p c:\drivers /e inf /d c:\windows\inf /a /s /q
Scan the "c:\drivers" directory and subdirectories for *.inf files then append the "c:\windows\inf" folder. It then will save the settings and quit.
3. spdrvscn /p "c:\windows\sysprep drivers" /e inf /d "c:\program files\inf files" /a /s /q
Scan the "c:\windows\sysprep drivers" directory and subdirectories for *.inf then append the "c:\program files\inf " folder. It then will save the settings and quit.
4. spdrvscn /p c:\sysprep\drivers /e inf /d c:\windows\inf;C:\other_drivers /a /s /q
Scan the "c:\sysprep\drivers" directory and subdirectories for *.inf then append the "c:\windows\inf" folder. It then will save the settings and quit.
5. spdrvscn /p c:\sysprep\drivers /e inf /d "c:\windows\inf;C:\nvidia drivers;c:\more drivers" /a /s /q
Scan the "c:\sysprep\drivers" directory and subdirectories for *.inf then append the "c:\windows\inf" folder, the "C:\nvidia drivers" folder, and the "c:\more drivers" folder. It then will save the settings and quit.
Run the program and get the GUI without any automation. This is the same as double clicking the program from explorer.
7. spdrvscn /p c:\sysprep\drivers /e inf /d c:\windows\inf /a /s
Scan the "c:\sysprep\drivers" directory and subdirectories for *.inf then append the "c:\windows\inf" folder. It then will save the settings, but it will leave the GUI open when it's done.
8. spdrvscn /?
Get the command-line help message. After you click okay the program will quit.
9. spdrvscn /p c:\sysprep\drivers /a /s /q
Scan the "c:\sysprep\drivers" directory and subdirectories for the default option of *.inf files. It then will save the settings and quit.
10. spdrvscn /a /s
Scan the default directory of "c:\sysprep\drivers" for all *.inf files and then save the settings, but it will leave the GUI open.
11. spdrvscn /a /s /q
Scan the default directory of "c:\sysprep\drivers" for all *.inf files and then save the settings and then it will quit when it's done.
12. spdrvscn /d c:\windows\inf /s /q
This command has little usefulness, at least in my eyes. But, what it does is take the path (or comma-delimited paths) that you supply and then saves those to the registry and then quits when it's done. I make note of it though because I imagine someone out there can use this feature.
13. spdrvscn /m "Image from ~month/~day/~year" /s /q
You most likely wouldn't want to do this, but there are some situations where you may find it useful. This will update the manufacturer entry for the computer (oeminfo.ini) with the text you provided, but it will also set the current date into the manufacturer string.
13. spdrvscn /o"Image from ~month/~day/~year" /s /q
You most likely wouldn't want to do this, but there are some situations where you may find it useful. This will update the duplicator string for the computer (OEMDuplicatorString) with the text you provided, but it will also set the current date into the duplicator string.
14. spdrvscn /p c:\sysprep\drivers /e inf /d c:\windows\inf;C:\other_drivers /m "Image from ~month/~day/~year" /o"Image from ~month/~day/~year" /a /s /q
Scan the "c:\sysprep\drivers" directory and subdirectories for *.inf then append the "c:\windows\inf" folder. It updates the duplicator and the manufacturer string with the current date. It then will save the settings and quit. The command for 14 is most likely split between multiple lines, but that's just because of word wrap and it should only be on a single logical line.
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.
ECHO SysPrep Driver Scanner with the default values supplied as arguments.
spdrvscn /p c:\sysprep\drivers /e inf /f /m "Image from ~month" /a /s /q
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.
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.
Program Name: SysPrep Driver Scanner
Download 32-bit Version: Vernalex.com (1.3.2) or Download.com (1.3.1)
Download 64-bit Version: Vernalex.com (1.3.2)
Current Version: 1.3.2 (final/release)
Release Date: 2007/02/23
Notes: The program was written in VC++ and it has been tested on Windows 2000, Windows XP and Windows Server 2003. 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.
You can also browse all previous versions by clicking here.
Return to top.