Diskpart Help


  1. Posts : 129
    Windows 10 Pro
       #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
      My Computer


  2. Posts : 31,691
    10 Home x64 (22H2) (10 Pro on 2nd pc)
       #2

    RBCC said:
    I would like to write a batch file that uses diskpart...
    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.

    Diskpart Help-image.png
      My Computers


  3. Posts : 14,023
    Win10 Pro and Home, Win11 Pro and Home, Win7, Linux Mint
       #3

    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.
      My Computers


  4. Posts : 31,691
    10 Home x64 (22H2) (10 Pro on 2nd pc)
       #4

    ...and be very careful how you test your script, Diskpart is very powerful, you could inadvertently wipe the wrong drive!
      My Computers


  5. Posts : 2,799
    Linux Mint 20.1 Win10Prox64
       #5

    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.
    Diskpart Help Attached Files
    • File Type: zip z.zip (528 Bytes, 5 views)
    Last edited by topgundcp; 30 Nov 2019 at 11:58.
      My Computer


  6. Posts : 4,144
    Windows 3.1 to Windows 11
       #6

    Note when using "Size" it references MB size
      My Computer


  7. Posts : 2,799
    Linux Mint 20.1 Win10Prox64
       #7

    Kyhi said:
    Note when using "Size" it references MB size
    Thanks, corrected for GB.
      My Computer


  8. Posts : 129
    Windows 10 Pro
    Thread Starter
       #8

    Thank you for your help

    - - - Updated - - -

    Can I use mkdir after I use diskpart in the text file?
      My Computer


  9. Posts : 31,691
    10 Home x64 (22H2) (10 Pro on 2nd pc)
       #9

    RBCC said:
    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.
      My Computers


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 11:22.
Find Us




Windows 10 Forums