4.3.1  Partition Manager (DiskPart.exe)

DiskPart Scripting

By using the DiskPart Command-Line Options command-line tool, you can create scripts to automate disk-related tasks, such as creating volumes or converting disks to dynamic disks. Scripting these tasks is useful if you deploy Windows by using unattended Setup or the Sysprep tool, which do not support creating volumes other than the boot volume.

For more information about DiskPart scripts, see "Disk Management" in the Microsoft Windows XP Professional Resource Kit.

To start a DiskPart script, at the command prompt, type:

diskpart /s scriptname.txt

where scriptname is the name of the text file that contains your script.

To redirect DiskPart's scripting output to a file, type:

diskpart /s scriptname.txt > logfile.txt

where logfile is the name of the text file where DiskPart writes its output.

When DiskPart starts, the DiskPart version and computer name display at the command prompt. By default, if DiskPart encounters an error while attempting to perform a scripted task, DiskPart stops processing the script and displays an error code (unless you specified the noerr parameter). However, DiskPart always returns errors when it encounters syntax errors, regardless of whether you used the noerr parameter. The noerr parameter enables you to perform useful tasks such as using a single script to delete all partitions on all disks regardless of the total number of disks.

The following table lists the DiskPart error codes.

Error Description

0

No errors occurred. The entire script ran without failure.

1

A fatal exception occurred. There might be a serious problem.

2

The parameters specified for a DiskPart command are incorrect.

3

DiskPart was unable to open the specified script or output file.

4

One of the services that DiskPart uses returned a failure.

5

A command syntax error occurred. The script failed because an object was improperly selected or was invalid for use with that command.

This section contains help with the following: