w10install/04_FormatStick.cmd

94 lines
1.7 KiB
Batchfile
Raw Normal View History

@echo off
set T=c:\TEMP
set DPARTSCRIPT=%T%\diskpart.txt
2021-03-19 18:25:28 +01:00
rem create temp directory ...
mkdir %T% 1>nul 2>nul
2021-03-17 00:22:50 +01:00
echo ====================
echo Format USB Stick ...
echo ====================
echo.
echo Showing disk list ...
> %DPARTSCRIPT% (
@echo.list disk
@echo.exit
@echo.
)
diskpart /s %DPARTSCRIPT% 2>nul
set DISK=
:askdisk
set /p DISK="Please select a disk: "
> %DPARTSCRIPT% (
@echo.select disk %DISK%
@echo.exit
@echo.
)
diskpart /s %DPARTSCRIPT% 1>nul 2>nul
2021-03-28 00:49:42 +01:00
if %ERRORLEVEL% EQU 0 (
echo OK using disk %DISK%
GOTO CONT1
) else (
echo ERROR: please select a valid disk number!
)
goto askdisk
:CONT1
set LABEL=
set /p LABEL="Please enter a label for the new disk: "
echo WARNING ! This will DELETE ALL data on disk number [ %DISK% ]
echo.
set answer=
:askyes
set /p answer="REALLY delete disk %DISK% (Y/N)? "
if /i "%answer:~,1%" EQU "Y" (
GOTO CONT2
)
if /i "%answer:~,1%" EQU "N" (
echo ABORT.
2021-03-19 18:25:28 +01:00
del /F %DPARTSCRIPT% 1>nul 2>nul
exit /b
)
echo Please type Y or N.
goto askyes
:CONT2
rem =====
rem MAIN
rem =====
> %DPARTSCRIPT% (
@echo.select disk %DISK%
@echo.clean
2022-08-26 11:26:25 +02:00
@echo.convert MBR
@echo.create partition primary
@echo.select partition 1
2021-08-29 16:42:13 +02:00
@echo.format fs=exfat LABEL="%LABEL%" quick
@echo.active
@echo.exit
@echo.
)
2022-08-26 11:26:25 +02:00
diskpart /s %DPARTSCRIPT%
2021-03-28 00:49:42 +01:00
if %ERRORLEVEL% NEQ 0 (
echo ERROR: while formatting the disk!
2021-03-19 18:25:28 +01:00
del /F %DPARTSCRIPT% 1>nul 2>nul
exit /b
)
2021-03-17 00:22:50 +01:00
echo READY.
echo USB stick formatted.
echo.
2021-03-19 18:25:28 +01:00
rem cleanup ...
del /F %DPARTSCRIPT% 1>nul 2>nul
rem =====
rem END
rem =====