JSI Tip 7282. The Windows XP DISkPART utility.

Jerold Schulman

October 5, 2003

2 Min Read
ITPro Today logo in a gray background | ITPro Today

I quote from the help file:

"DiskPart.exe is a text-mode command interpreter that enables you to manage objects (disks, partitions, or volumes) by using scripts or direct input from a command prompt. Before you can use DiskPart.exe commands, you must first list, and then select the object to give it focus. When an object has focus, any DiskPart.exe commands that you type will act on that object.

You can list the available objects and determine an object's number or drive letter by using the list disk, list volume, and list partition commands. The list disk and list volume commands display all disks and volumes on the computer. However, the list partition command only displays partitions on the disk that has focus. When you use the list commands, an asterisk (*) appears next to the object with focus. You select an object by its number or drive letter, such as disk 0, partition 1, volume 3, or volume C.

When you select an object, the focus remains on that object until you select a different object. For example, if the focus is set on disk 0 and you select volume 8 on disk 2, the focus shifts from disk 0 to disk 2, volume 8. Some commands automatically change the focus. For example, when you create a new partition, the focus automatically switches to the new partition.

You can only give focus to a partition on the selected disk. When a partition has focus, the related volume (if any) also has focus. When a volume has focus, the related disk and partition also have focus if the volume maps to a single specific partition. If this is not the case, focus on the disk and partition is lost."

If you just installed a second hard drive, you could script the creation of the partition and assignment of a drive letter, followed by formatting the partition:

diskpart /s diskpart.txt
FORMAT S: /FS:NTFS /V:My_Label

where diskpart.txt would contain:

REM Select future S: driveSELECT DISK 1REM Wipe the disk cleanCLEANREM Create a single Primary PartitionCREATE PARTITION PRIMARYREM Set the drive to mount at S:ASSIGN LETTER=S



Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like