w10install/06_Copy2Media.cmd

187 lines
4.5 KiB
Batchfile
Raw Normal View History

2020-12-25 20:08:46 +01:00
@echo off
2023-02-06 17:03:13 +01:00
set T=c:\temp
2023-01-02 17:15:02 +01:00
set W10=c:\TEMP\W10
set SOURCES=%W10%\sources
2023-02-07 16:39:44 +01:00
set BOOTFILE=boot.wim
set IMAGEFILE=install.wim
2022-06-21 22:55:51 +02:00
set SCRIPT_SETTINGS=scripts\settings.cmd
2022-06-19 16:40:47 +02:00
set COMPANY_SETTINGS=company\settings.cmd
2023-01-22 12:56:24 +01:00
set LANG=en-US
2023-02-08 22:48:50 +01:00
set FOURGB=4294967296
2023-01-22 17:58:47 +01:00
set MYUSER=
set MYNAME=
set MYPASS=
2020-12-25 20:08:46 +01:00
2021-03-18 00:08:40 +01:00
IF %1.==. GOTO USAGE
2022-06-19 16:40:47 +02:00
rem ===================
rem CONFIGFILE CHECK
rem ===================
2022-12-13 16:29:35 +01:00
echo searching for SCRIPT settings ...
if NOT EXIST %SCRIPT_SETTINGS% (
2023-01-02 14:33:56 +01:00
echo INFO: config file %SCRIPT_SETTINGS% NOT FOUND
2022-12-13 16:29:35 +01:00
) else (
echo OK. Loading SCRIPT settings ...
call %SCRIPT_SETTINGS%
2022-06-19 16:40:47 +02:00
)
2022-12-13 16:29:35 +01:00
echo searching for COMPANY settings ...
2022-06-19 16:40:47 +02:00
if NOT EXIST %COMPANY_SETTINGS% (
2022-12-13 16:29:35 +01:00
echo INFO: config file %COMPANY_SETTINGS% NOT FOUND
2022-06-19 16:40:47 +02:00
) else (
echo OK. Loading COMPANY settings ...
call %COMPANY_SETTINGS%
)
2021-03-17 00:22:50 +01:00
echo.
2023-01-02 17:15:02 +01:00
echo =================================
2023-02-20 10:35:26 +01:00
echo Copying all data to Media ...
2023-01-02 17:15:02 +01:00
echo =================================
echo.
2020-12-25 20:08:46 +01:00
2023-02-20 10:35:26 +01:00
set DRIVE=%1
2021-01-10 00:22:42 +01:00
2023-02-20 10:35:26 +01:00
if /I %DRIVE% == C: (
echo ERROR: cannot use drive %DRIVE% !
2021-01-10 15:49:37 +01:00
exit /b
)
2023-02-20 10:35:26 +01:00
if NOT EXIST %DRIVE% (
echo ERROR: drive %DRIVE% not found!
2021-01-10 00:22:42 +01:00
exit /b
)
2023-02-20 10:35:26 +01:00
echo using drive [ %DRIVE% ] ...
2023-02-08 22:48:50 +01:00
echo.
rem get drive type (is it fat32 ?) ...
2023-02-20 10:35:26 +01:00
for /f "tokens=5" %%A in ('@fsutil fsinfo volumeinfo %DRIVE%^|findstr /B "File System Name : "') do (@set DRIVETYPE=%%A)
2023-02-08 22:48:50 +01:00
echo INFO: DRIVETPYE = [ %DRIVETYPE% ]
2021-01-29 11:57:12 +01:00
rem =====
rem MAIN
rem =====
2023-01-11 15:12:49 +01:00
echo.
echo IMPORTANT:
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.
2023-02-08 22:48:50 +01:00
rem check SOURCE for files LARGER 4 GB in case FAT32 was chosen ...
if /i "%DRIVETYPE%" EQU "fat32" (
2023-02-14 01:03:07 +01:00
for /f "tokens=*" %%F in ('"dir /S /B /A-D %W10%"') do if %%~zF GTR %FOURGB% (
echo ERROR: The file [ %%F : %%~zF bytes ] is greater than 4GB in size - cannot copy this to a FAT32 filesystem!
2023-02-08 22:48:50 +01:00
exit /b
)
)
2023-01-11 15:26:22 +01:00
set answer=B
2021-01-10 00:22:42 +01:00
:ask
2023-01-11 15:26:22 +01:00
set /p answer="BIOS(default) or UEFI setup (B/U)? "
2021-01-10 00:22:42 +01:00
if /i "%answer:~,1%" EQU "B" (
2021-01-12 19:22:13 +01:00
echo selected: BIOS
2023-02-20 10:35:26 +01:00
copy /Y image\autounattend_BIOS_template.xml %DRIVE%\autounattend.xml
GOTO CONT
2021-01-10 00:22:42 +01:00
)
if /i "%answer:~,1%" EQU "U" (
2021-01-12 19:22:13 +01:00
echo selected: UEFI
2023-02-20 10:35:26 +01:00
copy /Y image\autounattend_UEFI_template.xml %DRIVE%\autounattend.xml
GOTO CONT
2021-01-10 00:22:42 +01:00
)
echo Please type B for BIOS or U for UEFI setup.
goto ask
2021-01-10 15:49:37 +01:00
:CONT
2021-01-10 00:22:42 +01:00
rem ask for user ...
if "@%localadmin%" NEQ "@" (
set MYUSER=%localadmin%
2022-06-19 16:40:47 +02:00
) else (
echo.
set /p MYUSER="Username (%MYUSER%)? "
)
rem ask for real name ...
if "@%localadmin_name%" NEQ "@" (
set MYNAME=%localadmin_name%
2022-06-19 16:40:47 +02:00
) else (
echo.
set /p MYNAME="Display Name (%MYNAME%)? "
)
rem ask for a password ...
if "@%localadmin_password%" NEQ "@" (
set MYPASS=%localadmin_password%
2022-06-19 16:40:47 +02:00
) else (
echo.
set /p MYPASS="Password (not set)? "
)
echo.
2023-02-20 10:35:26 +01:00
tools\searchreplace %DRIVE%\autounattend.xml ___MYUSER___ "%MYUSER%"
tools\searchreplace %DRIVE%\autounattend.xml ___MYNAME___ "%MYNAME%"
2023-02-20 12:00:51 +01:00
tools\searchreplace %DRIVE%\autounattend.xml ___MYPASS___ "%MYPASS%" /S
2023-02-20 10:35:26 +01:00
tools\searchreplace %DRIVE%\autounattend.xml ___MYLANG___ "%LANG%"
2023-02-07 16:39:44 +01:00
if NOT EXIST %SOURCES%\%BOOTFILE% (
echo DOH! no %BOOTFILE% in [ %SOURCES% ] found
2022-06-08 19:58:48 +02:00
exit /b
)
2021-03-17 13:05:50 +01:00
2023-02-07 16:39:44 +01:00
if NOT EXIST %SOURCES%\%IMAGEFILE% (
2023-02-20 10:35:26 +01:00
echo DOH! no %IMAGE% in [ %SOURCES% ] found
exit /b
2023-02-06 17:03:13 +01:00
2020-12-25 20:08:46 +01:00
)
2023-02-20 10:35:26 +01:00
echo copying all files in [ %W10% ] to drive %DRIVE% ...
robocopy %W10%\ %DRIVE% /MIR /256 /NDL /R:1 /J /XX
2023-01-02 17:15:02 +01:00
:CONT
2021-01-12 17:01:34 +01:00
if EXIST tools (
2021-03-31 14:49:02 +02:00
echo.
2023-02-20 10:35:26 +01:00
echo copying folder [ tools ] to drive %DRIVE% ...
robocopy tools %DRIVE%\tools /COPY:DT /FFT /XO /256 /NJH /NJS /NDL /R:1 /XF .gitignore
2021-01-12 17:01:34 +01:00
)
2021-03-28 18:19:09 +02:00
if EXIST software (
echo.
2023-02-20 10:35:26 +01:00
echo copying folder [ software ] to %DRIVE%\tools ...
robocopy software %DRIVE%\tools\software /COPY:DT /FFT /XO /MIR /256 /NJH /NJS /NDL /R:1 ^
2023-02-08 22:48:50 +01:00
/XF *.iso /XF *.txt /XF *.cmd /XF *.csv /XF .gitignore /XD .git
2021-03-28 18:19:09 +02:00
)
2023-01-01 18:04:13 +01:00
for %%P in (drivers scripts source optional personal company apps) do (
2021-01-10 15:49:37 +01:00
if EXIST %%P (
2021-01-10 23:14:52 +01:00
echo.
2023-02-20 10:35:26 +01:00
echo copying folder [ %%P ] to %DRIVE%\tools ...
robocopy %%P %DRIVE%\tools\%%P /COPY:DT /FFT /XO /MIR /256 /NJH /NJS /NDL ^
2023-02-08 22:48:50 +01:00
/R:1 /XF .gitignore /XD .git
2021-01-10 15:49:37 +01:00
)
)
2021-01-10 23:14:52 +01:00
echo.
2023-02-20 10:35:26 +01:00
echo copying autoconfig starter script to %DRIVE% ...
copy /Y image\StartAutoConfig.cmd %DRIVE%\
2021-03-17 00:22:50 +01:00
2022-06-18 10:41:57 +02:00
echo.
2023-02-20 10:35:26 +01:00
echo putting copytools script to %DRIVE% ...
copy /Y image\CopyTools.cmd %DRIVE%\
2022-06-18 10:41:57 +02:00
echo.
2023-01-02 17:15:02 +01:00
echo ======
echo READY.
echo ======
2021-01-10 15:49:37 +01:00
GOTO END
:USAGE
2023-02-20 10:35:26 +01:00
echo "usage: %0 <DRIVE>"
2021-02-24 22:26:55 +01:00
echo.
2021-01-10 15:49:37 +01:00
:END