I’m finalizing a Windows 2003 R2 build that will become our gold image, which will be the source of all new server deployments within our organization. One challenge I had to overcome was getting the CD-ROM/DVD drive to be set to drive Z: after the syspreped image is cloned and booted.
Many people are familiar with changing drive letters within the Device Management tool aka devmgmt.msc. I needed to automate this task so the CD-ROM drive, which shows up as drive D on my image after running sysprep, would be automatically set to drive Z.
To accomplish this, I needed three things:
- An entry in the [GuiRunOnce] section of my sysprep.inf file that calls a batch file after booting up the sysprep’ed image for the first time.
- The batch file mentioned in step 1, changeletter.cmd runs diskpart.exe, with the parameters supplied in drives.txt
- The drives.txt file, which details the diskpart.exe commands that change the CD-ROM’s drive letter from drive D to drive Z.
The applicable portion on my sysprep.inf file:
My changeletter.cmd file:
diskpart /s c:\drives.txt
My drives.txt file:
select disk 0 select volume d assign letter z noerr
Put all these pieces together, and your CD/DVD drive should be changed to drive letter Z after booting up the sysprepped image. Note that in the [GuiRunOnce] section of the sysprep.inf file, the part to the left of the equals sign is Command0, as is Command zero. If you wanted to run additional scripts, the next would be Command1, followed by Command2, etc.
If you’re curious about diskpart.exe, check out the details on syntax in KB300415.