2021-03-14 19:39:32 +01:00
|
|
|
@echo off
|
|
|
|
set T=c:\TEMP
|
|
|
|
set DPARTSCRIPT=%T%\diskpart.txt
|
|
|
|
|
2021-03-19 18:25:28 +01:00
|
|
|
rem create temp directory ...
|
2021-03-14 19:39:32 +01:00
|
|
|
mkdir %T% 1>nul 2>nul
|
|
|
|
|
2021-03-17 00:22:50 +01:00
|
|
|
echo ====================
|
2023-02-20 10:35:26 +01:00
|
|
|
echo Format Media ...
|
2021-03-17 00:22:50 +01:00
|
|
|
echo ====================
|
2021-03-14 19:39:32 +01:00
|
|
|
echo.
|
2023-01-02 17:15:02 +01:00
|
|
|
|
2023-02-21 08:02:13 +01:00
|
|
|
echo IMPORTANT HINT:
|
|
|
|
echo How is your target media formatted?
|
|
|
|
echo - use "exfat" for BIOS based installations only!
|
|
|
|
echo - use "fat32" for UEFI based installations only!
|
|
|
|
echo REASON: UEFI cannot read "exfat" filesystems and Windows setup will throw error code: 0x80042565
|
|
|
|
echo.
|
|
|
|
|
2021-03-14 19:39:32 +01:00
|
|
|
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 (
|
2021-03-14 19:39:32 +01:00
|
|
|
echo OK using disk %DISK%
|
|
|
|
GOTO CONT1
|
|
|
|
) else (
|
|
|
|
echo ERROR: please select a valid disk number!
|
|
|
|
)
|
|
|
|
|
|
|
|
goto askdisk
|
|
|
|
:CONT1
|
|
|
|
|
2023-02-20 10:35:26 +01:00
|
|
|
set FS=fat32
|
2022-09-09 21:08:15 +02:00
|
|
|
:askfs
|
2022-09-25 13:12:13 +02:00
|
|
|
echo.
|
2023-02-17 14:02:58 +01:00
|
|
|
set /p FS="Please select filesystem (fat32 or exfat) [fat32]: "
|
2022-09-09 21:08:15 +02:00
|
|
|
if /i "%FS%" EQU "fat32" (
|
2023-02-08 22:48:50 +01:00
|
|
|
echo IMPORTANT: maximum partition size for FAT32 is 32768!
|
|
|
|
echo maximum filesize for FAT32 is 4GB!
|
2022-09-09 21:08:15 +02:00
|
|
|
GOTO CONT2
|
|
|
|
)
|
|
|
|
if /i "%FS%" EQU "exfat" (
|
|
|
|
GOTO CONT2
|
|
|
|
)
|
|
|
|
if /i "%FS%" EQU "" (
|
|
|
|
GOTO CONT2
|
|
|
|
)
|
|
|
|
echo Please enter "exfat" or "fat32".
|
|
|
|
goto askfs
|
2023-01-22 17:15:06 +01:00
|
|
|
|
2022-09-09 21:08:15 +02:00
|
|
|
:CONT2
|
|
|
|
echo selected: %FS%
|
|
|
|
|
2023-02-20 10:00:21 +01:00
|
|
|
set SIZE=32768
|
2022-09-25 13:12:13 +02:00
|
|
|
:asksize
|
|
|
|
echo.
|
2023-02-20 10:00:21 +01:00
|
|
|
set /p SIZE="Please enter size in MB [%SIZE%]: "
|
2022-09-25 13:12:13 +02:00
|
|
|
|
|
|
|
if /i "%SIZE%" EQU "" (
|
|
|
|
GOTO CONT3
|
|
|
|
)
|
|
|
|
|
|
|
|
echo %SIZE%| findstr /r "^[1-9][0-9]*$">nul
|
|
|
|
if %errorlevel% neq 0 (
|
|
|
|
echo Please enter an integer number!
|
|
|
|
goto asksize
|
|
|
|
) else (
|
|
|
|
echo selected size = %SIZE% [MB]
|
|
|
|
set SIZE=size=%SIZE%
|
|
|
|
)
|
2023-01-22 17:15:06 +01:00
|
|
|
|
2022-09-25 13:12:13 +02:00
|
|
|
:CONT3
|
|
|
|
|
|
|
|
echo.
|
2023-02-20 10:35:26 +01:00
|
|
|
set LABEL=W10-20H2
|
|
|
|
set /p LABEL="Please enter a label for the new disk [%LABEL%] : "
|
2021-03-14 19:39:32 +01:00
|
|
|
|
2023-02-20 10:35:26 +01:00
|
|
|
echo WARNING ! This will DELETE ALL data on disk number [%DISK%]
|
2021-03-14 19:39:32 +01:00
|
|
|
echo.
|
|
|
|
set answer=
|
|
|
|
:askyes
|
|
|
|
set /p answer="REALLY delete disk %DISK% (Y/N)? "
|
|
|
|
if /i "%answer:~,1%" EQU "Y" (
|
2022-09-09 21:08:15 +02:00
|
|
|
GOTO CONT3
|
2021-03-14 19:39:32 +01:00
|
|
|
)
|
|
|
|
if /i "%answer:~,1%" EQU "N" (
|
|
|
|
echo ABORT.
|
2021-03-19 18:25:28 +01:00
|
|
|
del /F %DPARTSCRIPT% 1>nul 2>nul
|
2021-03-14 19:39:32 +01:00
|
|
|
exit /b
|
|
|
|
)
|
|
|
|
echo Please type Y or N.
|
|
|
|
goto askyes
|
2022-09-09 21:08:15 +02:00
|
|
|
:CONT3
|
2021-03-14 19:39:32 +01:00
|
|
|
|
|
|
|
rem =====
|
|
|
|
rem MAIN
|
|
|
|
rem =====
|
|
|
|
|
|
|
|
> %DPARTSCRIPT% (
|
|
|
|
@echo.select disk %DISK%
|
|
|
|
@echo.clean
|
2022-08-26 11:26:25 +02:00
|
|
|
@echo.convert MBR
|
2022-09-25 13:12:13 +02:00
|
|
|
@echo.create partition primary %SIZE%
|
2021-03-14 19:39:32 +01:00
|
|
|
@echo.select partition 1
|
2022-09-09 21:08:15 +02:00
|
|
|
@echo.format fs="%FS%" LABEL="%LABEL%" quick
|
2021-03-14 19:39:32 +01:00
|
|
|
@echo.active
|
2022-12-29 10:49:17 +01:00
|
|
|
@echo.assign
|
2021-03-14 19:39:32 +01:00
|
|
|
@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 (
|
2021-03-14 19:39:32 +01:00
|
|
|
echo ERROR: while formatting the disk!
|
2021-03-19 18:25:28 +01:00
|
|
|
del /F %DPARTSCRIPT% 1>nul 2>nul
|
2021-03-14 19:39:32 +01:00
|
|
|
exit /b
|
|
|
|
)
|
2023-02-20 10:35:26 +01:00
|
|
|
echo Media formatted.
|
2021-03-14 19:39:32 +01:00
|
|
|
|
2021-03-19 18:25:28 +01:00
|
|
|
rem cleanup ...
|
|
|
|
del /F %DPARTSCRIPT% 1>nul 2>nul
|
|
|
|
|
2023-01-02 17:15:02 +01:00
|
|
|
echo.
|
|
|
|
echo ======
|
|
|
|
echo READY.
|
|
|
|
echo ======
|
2023-02-20 10:00:21 +01:00
|
|
|
|