w10install/06_Copy2Stick.cmd

141 lines
3.1 KiB
Batchfile
Raw Normal View History

2020-12-25 20:08:46 +01:00
@echo off
2021-01-10 15:49:37 +01:00
set SOURCES=c:\TEMP\W10\sources
2021-03-17 13:05:50 +01:00
set BOOT=boot.wim
set IMAGE=install_FINAL.esd
set ALTIMAGE=install_FINAL_lastrun.esd
2020-12-25 20:08:46 +01:00
2021-03-18 00:08:40 +01:00
IF %1.==. GOTO USAGE
2021-03-17 00:22:50 +01:00
echo.
echo =====================
echo Prepare USB Stick ...
echo =====================
2020-12-25 20:08:46 +01:00
2021-01-10 15:49:37 +01:00
set USBDRIVE=%1
2021-01-10 00:22:42 +01:00
2021-01-10 15:49:37 +01:00
if /I %USBDRIVE% == C: (
echo ERROR: cannot use drive %USBDRIVE% !
exit /b
)
if NOT EXIST %USBDRIVE% (
echo ERROR: drive %USBDRIVE% not found!
2021-01-10 00:22:42 +01:00
exit /b
)
echo using drive %USBDRIVE% ...
2021-01-29 11:57:12 +01:00
rem =====
rem MAIN
rem =====
2021-01-12 19:22:13 +01:00
set answer=
2021-01-10 00:22:42 +01:00
:ask
set /p answer="BIOS or UEFI setup (B/U)? "
if /i "%answer:~,1%" EQU "B" (
2021-01-12 19:22:13 +01:00
echo selected: BIOS
copy /Y boot\autounattend_BIOS_template.xml %USBDRIVE%\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
copy /Y boot\autounattend_UEFI_template.xml %USBDRIVE%\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 ...
echo.
set MYUSER=support
set /p MYUSER="Username (%MYUSER%)? "
echo MYUSER = %MYUSER%
rem ask for real name ...
echo.
2021-03-28 17:55:17 +02:00
set MYNAME=Support User
set /p MYNAME="Display Name (%MYNAME%)? "
echo MYNAME = %MYNAME%
rem ask for a password ...
echo.
set MYPASS=
set /p MYPASS="Password (not set)? "
echo MYPASS = %MYPASS%
echo.
2021-03-28 17:55:17 +02:00
tools\searchreplace %USBDRIVE%\autounattend.xml ___MYUSER___ "%MYUSER%"
tools\searchreplace %USBDRIVE%\autounattend.xml ___MYNAME___ "%MYNAME%"
tools\searchreplace %USBDRIVE%\autounattend.xml ___MYPASS___ "%MYPASS%"
2021-03-17 13:05:50 +01:00
echo.
echo copying [ %BOOT% ] to drive %USBDRIVE% ...
robocopy %SOURCES% %USBDRIVE%\sources %BOOT% /J /NJH
if EXIST %SOURCES%\%IMAGE% (
echo.
2021-03-16 23:51:45 +01:00
echo copying [ %IMAGE% ] to drive %USBDRIVE% ...
robocopy %SOURCES% %USBDRIVE%\sources %IMAGE% /J /NJH
rem move image in place ...
del /F %USBDRIVE%\sources\install.esd 2>nul
move /Y %USBDRIVE%\sources\%IMAGE% %USBDRIVE%\sources\install.esd
rem rename image in sources directory ...
move /Y %SOURCES%\%IMAGE% %SOURCES%\%ALTIMAGE%
) else (
echo.
echo INFO: NOT copying image!
echo.
echo HINT: please rename
echo [ %SOURCES%\%ALTIMAGE% ]
echo to [ %SOURCES%\%IMAGE% ]
echo for force copy of image.
2020-12-25 20:08:46 +01:00
)
:CONT
2021-01-12 17:01:34 +01:00
echo.
if EXIST tools (
2021-03-17 00:22:50 +01:00
echo copying folder [ tools ] to drive %USBDRIVE% ...
2021-01-12 19:22:13 +01:00
robocopy tools %USBDRIVE%\tools /COPY:DT /FFT /XO /256 /NJH /NJS /NDL /XF .gitignore
2021-01-12 17:01:34 +01:00
)
2021-03-28 18:19:09 +02:00
if EXIST software (
echo.
echo copying folder [ software ] to %USBDRIVE%\tools ...
2021-03-28 18:20:10 +02:00
robocopy software %USBDRIVE%\tools\software /COPY:DT /FFT /XO /MIR /256 /NJH /NJS /NDL ^
2021-03-28 18:19:09 +02:00
/XF *.iso /XF *.txt /XF *.cmd /XF *.csv /XF .gitignore /XD .git
)
for %%P in (scripts source optional personal) do (
2021-01-10 15:49:37 +01:00
if EXIST %%P (
2021-01-10 23:14:52 +01:00
echo.
2021-03-17 00:22:50 +01:00
echo copying folder [ %%P ] to %USBDRIVE%\tools ...
2021-03-14 00:34:27 +01:00
robocopy %%P %USBDRIVE%\tools\%%P /COPY:DT /FFT /XO /MIR /256 /NJH /NJS /NDL /XF .gitignore /XD .git
2021-01-10 15:49:37 +01:00
)
)
2021-01-10 23:14:52 +01:00
echo.
2021-01-10 15:49:37 +01:00
echo copying custom setup script to %USBDRIVE% ...
2021-03-16 23:51:45 +01:00
copy /Y boot\CustomSetup.cmd %USBDRIVE%\
2021-03-17 00:22:50 +01:00
echo READY.
echo.
2021-01-10 15:49:37 +01:00
rem =====
rem END
rem =====
GOTO END
:USAGE
echo "usage: %0 <USBDRIVE>"
2021-02-24 22:26:55 +01:00
echo.
2021-01-10 15:49:37 +01:00
:END