问题
I'm trying to make a Diskpart script that takes in a value of a drive letter, and then deletes all the partitions of the corresponding device of that drive letter.
The script that I currently have is
select Disk 1
select partition 0
delete partition
select partition 1
delete partition
but the obvious problem is that I need to convert a drive letter into it's corresponding disk, and then loop through all the partitions that exist, rather than hard-coding deleting the first two partitions in.
I'm rather new to diskpart, so would appreciate some help with this.
回答1:
That's actually much easier than you think. :-)
select volume x
clean
When you select
a volume it implicitly selects the disk containing the volume, and the clean
command deletes all partitions on the selected disk.
回答2:
Try this out..
Diskpart
list disk
Select disk1 //put the disk you want
clean
Let me know what happens
来源:https://stackoverflow.com/questions/36268193/diskpart-script-to-remove-all-partitions