First, you should know that there are no guarantees. I've yet to find a technique that always gets every file needed by every driver. But I can recommend two approaches, either of which will get the vast majority and quite likely all of them. As an extra precaution, you might use both.
The first is driverback.bat, a batch file I wrote when I last answered this question in 2005. Copy and paste this text into Notepad and save it as driverback.bat. This makes for an extremely easy backup and a reasonably easy restore, although it backs up far more files than you're likely to need. Another problem: It doesn't work in Vista–one more reason why I'm giving an alternative solution.
Running my batch file copies a great many files to a folder inside My Documents called driverback. Copy this folder to an external drive or burn it to CD for safe keeping.
To restore your drivers to a fresh XP installation, connect or insert the media containing your driverback backup. Select Start, Run, type sysdm.cpl, and press ENTER. Click the Hardware tab, then the Device Manager button.
Repeat the following steps for each item listed that displays a yellow question mark:
- Right-click the item and select Update Driver.
- In the resulting Hardware Update Wizard, select Install from a list or specific location (Advanced) and click Next.
- Check Include this location in the search and point it to your driverback folder. Click Next.
- If the installation pauses because it can't find a file, point it to your driverback folder.
If you're using Vista, don't trust my admittedly crude batch file, or just want two backups, consider Innovative Solution's free DriverMax. (Free, yes, but you still must register it if you wish to keep using it.)
Once installed and registered, it backs up and restores drivers with almost no fuss.