I recently needed to create and format a disk partition from a batch file. To make this more fun, I needed to run the batch file from a USB disk which mounted as the D drive, but I needed the new partition to be the D drive when finished.
in the interest of full disclosure, there are other ways to do this, but I wanted to do it from a batch file because I was doing other things from batch files at the time – so this method fit in.
I started this by doing running diskpart and learning what could do and how to do it. To start I knew that I needed to create disk 0 partition 2 and format it with NTFS. The commands in diskpart are:
select disk 0 create partition primary noerr select part 2 format fs=ntfs label=Data quick
These command create and partition disk 0 partition 2 and format the disk. But what I found is that the USB disk was the D drive and the new partition was the F driver, not what I want. But if before creating the partition, I changed the USB disk to be the F drive solving the problem:
select volume 1 assign letter=F
And just to be sure, before formatting the disk, I could set the new partition to be the D drive with:
assign letter=D
Now I have a way to use diskpart to do the work, but what about from a batch file? For that, all that is needed is a script, or text file, with all of the diskpart commands and tell disk part to run the script:
diskpart /s CreateDDrive.txt
and the contents of CreateDDrive.txt is:
select volume 1 assign letter=F select disk 0 create partition primary noerr select part 2 assign letter=D format fs=ntfs label=Data quick
And that is how I did this from a batch file.
Copyright © 2014 – Bruce Eitman All Rights Reserved
Re: Windows 10 IoT Core: Shutdown and Reboot the Raspberry Pi
Bruce, I noticed that you are sending a REST web request for controlling the pi. I looked online a for...
-- Waleed Elmandouh
Re: Windows 10 IoT Core: Getting the MAC Address from Raspberry Pi
Hi. This no longer works for me in the iot-core custom OEM-build/FFU. They have changed the access levels...
-- GG
Hi, since I am having trouble with this intervace in an OEM-custom Image/FFU scenario, I wonder, how...
I like your project here, and I've used it, and at one time it worked, at least with an older version...
-- integral
Nifty, Bruce!
-- David Jones
Hi Bruce, Good to know you are playing with Windows 10 IoT, and thanks for sharing these great finding...
-- Samuel Phung