@echo off
call check-for-admin
if %ERRORLEVEL% neq 0 exit /b

set OPT=..\optional
set SOFTWARE=..\software
set MSI=freeoffice-setup.msi
set STARTMENU="%PROGRAMDATA%\Microsoft\Windows\Start Menu\Programs"

if NOT EXIST %SOFTWARE%\%MSI% (
  echo ERROR: %SOFTWARE%\%MSI% not found!
  exit /b
)

echo ####### %0 #######

cd %SOFTWARE%
@echo on
msiexec /i %MSI% /qb INSTALLTM=1 INSTALLPM=1 INSTALLPR=1 ^
  /l*v c:\temp\freeoffice.log
@echo off
del /F c:\temp\freeoffice.log
cd %OPT%

echo installing desktop icons ...
copy /Y "%PROGRAMDATA%\Microsoft\Windows\Start Menu\Programs\Softmaker FreeOffice 2021\PlanMaker.lnk" ^
  %PUBLIC%\Desktop\PlanMaker.lnk
copy /Y "%PROGRAMDATA%\Microsoft\Windows\Start Menu\Programs\Softmaker FreeOffice 2021\Presentations.lnk" ^
  %PUBLIC%\Desktop\Presentations.lnk
copy /Y "%PROGRAMDATA%\Microsoft\Windows\Start Menu\Programs\Softmaker FreeOffice 2021\TextMaker.lnk" ^
  %PUBLIC%\Desktop\Textmaker.lnk

rem refresh desktop (W10 style)
ie4uinit.exe -show

echo ####### %0 #######

rem set filetypes ...
if EXIST ..\scripts\set-filetypes.cmd (
  call ..\scripts\set-filetypes.cmd
)

pause

