Last active
September 10, 2017 19:30
-
-
Save mansouryaacoubi/aed3a3c89960ee9b4aa0592c530a2d11 to your computer and use it in GitHub Desktop.
Clean disk, create primary partition and format disk with diskpart using Batch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
REM @author Mansour Yaacoubi | |
REM @filename cleanformatdisk.bat | |
REM @task Cleans disk, creates primary partition and formats disk | |
REM f.e. for raspberry pi drives before writing new image of SD-Card | |
@echo off | |
cls | |
net session >nul 2>&1 | |
IF %ERRORLEVEL% == 0 GOTO START | |
echo Please run this batch as administrator | |
GOTO EOF | |
:START | |
SET fname="%TEMP%\%RANDOM%dplist.txt" | |
echo list disk > %fname% | |
diskpart /s %fname% | |
echo. | |
SET /P sel="Select disk: " | |
echo select disk %sel% > %fname% | |
echo clean >> %fname% | |
echo clean >> %fname% | |
echo clean >> %fname% | |
echo convert gpt >> %fname% | |
echo create partition primary >> %fname% | |
echo format quick fs=fat32 >> %fname% | |
diskpart /s %fname% | |
:EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment