@echo off
set T=%SystemDrive%\TEMP
set EXE=officedeploymenttool-setup.exe
set CONFIG=..\optional\config\office2019-standard.xml

if NOT EXIST %EXE% (
  echo ERROR: %EXE% not found!
  echo HINT: use "download-from-source optional"
  exit /b
)

echo unpacking office deployment tool ...
%EXE% /extract:%T% /quiet /passive

echo starting download ...
%T%\setup.exe /download %CONFIG%

echo packing files with 7zip...
7z a -aoa -r -y -mx0 -sdel office2019-standard %T%\Office

rem cleanup ...
del /F /Q %T%\setup.exe 1>nul 2>nul
del /F /Q %T%\configuration*.xml 1>nul 2>nul
rd /S /Q %T%\Office 2>nul