New
#1
Diskpart Help
I would like to write a batch file that uses diskpart to partition 6 partitions, assigns drive letters ,to 60 ,20,20,250,80 , 80,DVD and USB Flash and formats the partitions to NTFS . How is this done? John
I would like to write a batch file that uses diskpart to partition 6 partitions, assigns drive letters ,to 60 ,20,20,250,80 , 80,DVD and USB Flash and formats the partitions to NTFS . How is this done? John
Not possible from a batch file. However, you can call DISKPART /S and give it a text file of Diskpart commands as a script to achieve what you want. See Microsoft's documentation here.
https://docs.microsoft.com/en-us/win...s-and-examples
Although the documentation says it refers to Windows Server, I've tested that it also works in Windows 10 Home.
And leave the DVD drive out of the list, not much you can do with it as any formatting is done on the disc. NTFS on a USB Thumb drive will work if not using it on a Macintosh computer, usually has read-only support without a third-party software, not an issue on Windows or Linux machines.
...and be very careful how you test your script, Diskpart is very powerful, you could inadvertently wipe the wrong drive!
Download the attachment.
Open admin command prompt then type the batch file name to run (z.bat)
WARNING: Be careful. select the correct disk.
NOTE: Since you create more than 4 partitions, I assume that the disk will be a GPT disk.
Last edited by topgundcp; 30 Nov 2019 at 11:58.
Thank you for your help
- - - Updated - - -
Can I use mkdir after I use diskpart in the text file?
No, not yet. The diskpart script created by that batch file just creates and formats the partitions. It needs some more diskpart commands added before the 'echo >> %temp%\diskpart.txt exit' line. For each partition you'll need a SELECT PARTITION command followed by an ASSIGN LETTER= command to give it a drive letter.
Only once each partition has a drive letter will you be able to use MKDIR commands (placed after the line 'diskpart /s %temp%\diskpart.txt') to create folders on those drive letters.