@echo off
set "OFFICE_VERSION=Office2021"
set "CONFIG_FILE=%~dp0Office\%OFFICE_VERSION%(Excel,PowerPoint,Publisher,Word)_Configuration.xml"
if not exist "%CONFIG_FILE%" (
echo Configuration file not found: "%CONFIG_FILE%"
exit /b 1
)
call "%~dp0Office\setup.exe" /download "%CONFIG_FILE%"
if %errorlevel% neq 0 (
echo Installation failed with error code %errorlevel%.
exit /b %errorlevel%
)
echo Installation successful.
set command to define variables for the Office version and configuration file name. The if not exist command is used to check if the configuration file exists before running the installation. The call command is used to run the setup.exe file with the specified configuration file. Finally, the if statement is used to check the errorlevel after the installation completes and print an appropriate message based on the error code.