Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

How to automatically assign a drive letter by using the Diskpart.exe command on a Windows Server 2003-based computer or on a Windows XP-based computer


View products that this article applies to.

Introduction

This article describes how to automatically assign a drive letter by using the Diskpart.exe command in the Sysprep.inf file and in the Cmdlines.txt file. The Diskpart.exe command can be used together with the Sysprep tool to deploy a Microsoft Windows Server 2003-based computer or a Microsoft Windows XP-based computer.

↑ Back to the top


More information

To automatically assign a drive letter, first create the DiskPart script, and then run the Sysprep tool by using one of the following methods.

DiskPart script sample

The following script (Script.txt) is used to assign the drive letter of the second partition to drive X. This script assumes that you have divided the hard disk that connects to the computer into two partitions.
select disk 0
select partition 2
remove noerr
assign letter=X noerr

Method 1: Use mini-setup

  1. Create the distribution folder for the Sysprep tool in the following location:
    C:\sysprep\i386\$OEM$
  2. Add the following line to the "[Commands]" section of the Cmdlines.txt file to run the DiskPart script (Script.txt):
    DISKPART /s C:\sysprep\OPTION\script.txt
  3. Add the following line to the "[Unattended]" section of the Sysprep.inf file:
    InstallFilesPath = C:\sysprep\i386
  4. Copy the Cmdlines.txt file into the folder that you created in step 1.
  5. Save the DiskPart script file in the following folder:
    C:\sysprep\OPTION
  6. Run the Sysprep.exe file by using the -mini switch. For more information about the general methods of Windows deployment when you use the Sysprep tool, click the following article number to view the article in the Microsoft Knowledge Base:
    302577 How to use the Sysprep tool to automate successful deployment of Windows XP

Method 2: Use the Out of Box Experience (OOBE) Wizard

Note The OOBE Wizard is available only in Windows XP.
  1. Add the following line to the "[GuiRunOnce]" section of the Unattend.txt file to run the DiskPart script:
    DISKPART.EXE /s C:\sysprep\OPTION\script.txt
  2. Save the DiskPart script file in the following location:
    C:\sysprep\OPTION
  3. Run the Sysprep.exe file. For more information about the general methods of Windows deployment when you use the Sysprep tool, click the following article number to view the article in the Microsoft Knowledge Base:
    302577 How to use the Sysprep tool to automate successful deployment of Windows XP

↑ Back to the top


References

For more information about how to assign the drive letter during the deployment of the operating systems, click the following article numbers to view the articles in the Microsoft Knowledge Base:
307844 How to change drive letter assignments in Windows XP
300415 A description of the Diskpart command-line utility
Windows operating systems typically cannot modify the drive letters that are assigned to the system drive or to the boot drive. For more information about how to change the drive letter that is assigned to the system drive or to the boot drive, click the following article numbers to view the articles in the Microsoft Knowledge Base:
223188 How to restore the system/boot drive letter in Windows
830577 How to set the drive letter for the system drive when you install Microsoft Windows Server 2003

↑ Back to the top


Keywords: KB928543, kbsyspreptool, kbexpertiseinter, kbhowto, kbinfo, kbharmony

↑ Back to the top

Article Info
Article ID : 928543
Revision : 4
Created on : 2/12/2007
Published on : 2/12/2007
Exists online : False
Views : 390