Link to home
Start Free TrialLog in
Avatar of armasmike
armasmike

asked on

Diskpart script help

I have a txt file that has this

select disk 0
clean

create partition primary size=100
select partition 1
format quick fs=ntfs label="System"
assign letter=S

active

create partition primary
select partition 2
format quick fs=ntfs label="Windows"
assign letter=W
list volume
exit

And to run this as a script

i use diskpart.exe /s WipeC.txt

BUT i am booting of a usb with a label name "images"

This has only happen one time but my script wiped my usb because it was disk 0.

Is there a way to check if disk 0 is label "images" if it is DON'T wipe it.
Avatar of Neil Russell
Neil Russell
Flag of United Kingdom of Great Britain and Northern Ireland image

A "DISK" does not have a label, a partition has a label.  so that is no use and diskpart does not know about labels.

You could run a diskpart script that just listed out the DISKs to a text file and then parse the textfile to decide what disk to wipe.
ASKER CERTIFIED SOLUTION
Avatar of Neil Russell
Neil Russell
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of armasmike
armasmike

ASKER

I have not learn PowerShell yet. it's on my bucket list but at this time can i output the diskpart info to a text file then use vbs to find out id Disk 0 is label name "images" if so DON'T Wipe it and stop.