

When using the diskpart command as a part of a script, we recommend that you complete all of the diskpart operations together as part of a single diskpart script.


For example, here's a script that wipes a disk and then creates a 300 MB partition for the Windows Recovery Environment: select disk 0įormat quick fs=ntfs label=Windows RE tools You can start a line with rem to make the line a comment. To create a diskpart script, create a text file that contains the Diskpart commands that you want to run, with one command per line, and no empty lines. Scripting these tasks is useful if you deploy Windows by using unattended Setup or the Sysprep tool, which do not support creating volumes other than the boot volume. Use diskpart /s to run scripts that automate disk-related tasks, such as creating volumes or converting disks to dynamic disks. Applies to: Windows Server 2022, Windows Server 2019, Windows Server 2016, Windows Server 2012 R2, Windows Server 2012
