@echo off
set SOURCES=%SystemDrive%\TEMP\W10\sources
set BOOT=%SystemDrive%\TEMP\BOOT
set SETTINGS=..\scripts\settings.cmd

if EXIST %SETTINGS% (
  call %SETTINGS%
) else (
  set LANG=en-US
)
echo LANG=%LANG%

if NOT EXIST %BOOT%\winsetup.exe (
  echo renaming Windows setup.exe to boot image ...
  move /Y %BOOT%\setup.exe %BOOT%\winsetup.exe
)

echo setting language in boot image ...
dism /image:%BOOT% /Set-InputLocale:%LANG% || exit /b 1
dism /image:%BOOT% /Set-SysLocale:%LANG% || exit /b 1

echo replacing setup.exe with our installer utility ...
copy /Y installer.exe %BOOT%\setup.exe

if EXIST ..\company\snapshot64.exe (
  echo copying LICENSED snapshot64.exe to boot image ...
  copy /Y ..\company\snapshot64.exe %BOOT% 
) else (
  echo copying STANDARD snapshot64.exe to boot image ...
  copy /Y ..\software\snapshot64.exe %BOOT%
)

echo copy netuse helper script to boot image ...
copy /Y netuse.cmd %BOOT%

echo unmounting and committing changes to %SOURCES%\boot.wim ...
dism /Unmount-Wim /MountDir:%BOOT% /Commit  || exit /b 1

