Although there are plenty of commercial disk imaging products out there, such as Acronis True Image, PowerQuest Drive Image, and Norton Ghost, you don’t need these programs to create a hard drive image. You can use a boot disk and a simple batch file to copy the entire contents of a PC’s hard disk to a designated location. Once the drive’s contents have been copied, you can burn the information to a CD and then use this CD in conjunction with a boot disk to reimage a crashed system or new computer.

A few words of warning
Before I give you the actual batch file code, there are a couple of issues you need to be aware of.

FAT and FAT32 only
First, this technique is designed to work only with Windows 9x or Windows Me machines. It is possible to use the technique on a Windows NT, 2000, or XP machine, but only on FAT or FAT32 partitions. If you’re using the technique to set up a new Windows NT, 2000, or XP machine, you must prepare the new machine’s boot sector prior to the operation. For the purposes of this article, I’ll assume that you’re using Windows 9x or Windows Me.

Hardware conflicts
The next problem that you need to be aware of is that the technique involves making an exact copy of the original machine. This is fine if you’re creating a CD that will be used to reimage that specific PC, but hardware conflicts and IP address conflicts can occur if you use the CD on different machines.

Hardware conflicts will occur if the PC you’re imaging has different hardware than the PC from which the image was made. When I developed the batch file code in this article, I was working for the U.S. Army. Since the Army tends to buy several thousand duplicate PCs at a time, this technique worked well in that environment. I just made three or four different CDs—one for each standard configuration that existed on the base.

If the PC that you’re imaging doesn’t have identical hardware to the one that you made the image from, several things could happen. Sometimes, the configurations will be similar enough that the new system will work fine in spite of the differences. Other times, the system will work fine except for maybe one or two devices (e.g., network cards, modems); other times, Windows won’t even boot or you’ll get the infamous Blue Screen of Death. Most of the time, though, you can solve any of these problems by booting the PC into Safe mode and replacing the current device drivers with the drivers that were intended for that machine.

IP address conflicts
For most people, the IP address issue won’t be a problem because most of the time, workstations are configured to use dynamic IP addresses assigned by a DHCP server. If your PCs use static IP addresses, though, any PCs you set up using the image file will inherit the IP address of the PC you made the image CD from.

If you run into this situation, you must do one of two things after copying the image CD to a computer. One solution is to leave the network cable unplugged. After the operation completes, you can boot Windows, change the IP address, reboot the machine, and plug the network cable back into the PC. The other solution is to boot to Safe mode, change IP addresses, and then boot Windows normally.

If your network uses static IP addresses, before you make the image CD, configure the PC that you’re creating the image from to use a dynamic IP address. You can then make the image and reset the PC to use its original IP address. The idea behind this technique is that there’s absolutely no danger of the PC’s IP address being accidentally assigned to other computers.

Creating the image
Since creating the image CD involves copying some system files, the creation process must take place outside of Windows. If Windows were to be running, some of the necessary system files would be in use and therefore locked. To create the image CD, you must boot the system from a boot disk rather than booting in the usual manner. (Click here to learn more about creating a boot disk.)

The problem is that many boot disks don’t contain mechanisms for accessing a network. Because of these issues, I recommend creating a folder on a hard drive partition other than the one you’ll be copying and then copying the image files into that folder. When the copy process completes, you can either burn the folder’s contents to a CD (if the machine has a CD burner), or you can copy the folder to a network drive and then create a CD from that copy.

For the purposes of this article, I’ll assume that you’re copying all of the files on C: to a folder called BACKUP on D:. (Remember: Because I’m copying all the files on C: to D:, D: will need to be larger than C:.) To do so, your batch file would include the following commands:
XCOPY C:\*.* D:\BACKUP /E /V /C /I /H /Y

This batch file switches to the D: drive and makes a directory called BACKUP. The batch file then switches to the A: drive so that it can run the XCOPY command (which you should have on your boot disk). The XCOPY command then copies all of the files on the C: drive to the D: drive. The switches that I’ve used with XCOPY do the following:

  • /E copies all subdirectories including the empty ones.
  • /V verifies each file after it’s been copied.
  • /C continues the copy process should an error occur.
  • /I tells XCOPY that if a specific destination doesn’t exist, assume that the destination must be a folder.
  • /H copies all hidden and system files.
  • /Y suppresses to prompt that asks you to confirm whether or not you want to overwrite a file.

Once you’ve copied all the files on C: to the BACKUP folder on D:, you can burn this information to a CD.

Restoring the image
After you’ve created the image CD, the next trick is to use the image CD to fix a failing PC or to configure a new PC. To do so, boot the PC from your boot disk and then use a batch file like this one. This batch file assumes that Windows will be installed on C: and that E: is the CD-ROM drive:
XCOPY *.* C:\ /E /V /C /I /H /Y /R

There are only two differences in this XCOPY command and the one that I used to create the image. The first difference is the source and destination paths. The second difference is the addition of the /R switch. The /R switch tells XCOPY to overwrite any files that might already exist that are flagged as read only.

Once you’ve copied all the files from your image CD to the PC hard drive, you should be able to boot the PC normally.