Diskpart script to remove all partitions [closed]

百般思念 提交于 2019-12-11 04:45:12

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!