Using DISKPART to Improve Deployment Efficiency

DISKPART is a small, scriptable command-line utility that ships with Windows XP Professional, which allows you to create, convert and delete disk partitions and software RAID arrays. It mirrors some of the functions available in the Disk Management MMC Snap-In, which you can access from Computer Management under Administrative Tools.

This utility can help speed up the process of building and testing your Embedded runtime. For example, if you find yourself needing to rebuild and redeploy your runtime fairly often, you might create a quick shell script that simply deletes and recreates your target partition, quick-formats it, and then copies the image from your development environment. This is considerably faster (and, in some cases, cleaner and safer) than just deleting the old image before copying the new one.

Here's an example of a simple automated process on a system that boots your runtime image from the D: drive (with a safe partition on C:).

First, create a script file that deletes the D: partition and then creates a new primary partition in its place:

rem replace_part.txt
rem ----------
select disk 0
select partition 2
delete partition
create partition
primary assign

Save the above file to replace_part.txt (or any filename you prefer), then create a batch file to run this script, format the newly created partition, then copy over the new runtime and reboot. Note that this script assumes that the new partition is assigned the drive letter D:.

rem prepbuild.bat
rem ----------
diskpart /s replace_part.txt
format d: /q /fs:fat32 /y
xcopy \\devmachine\share\imagefolder d:\ /s
shutdown -r -t 0

Save this file as prepbuild.bat (or any batch filename you prefer), and then just run this file whenever you need to copy over a new runtime image. Quick and simple!

For more information on DISKPART, please refer to the following MSDN article: KB Article 300415

- Matt