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

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

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

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

echo installing PDF24 ...
cd %SOFTWARE%
@echo on
msiexec /i %MSI% /q
@echo off
cd %OPT%

echo tweaking PDF24 ...
reg import %CONFIG%

echo removing Desktop icons ...
del /F /Q "%PUBLIC%\Desktop\PDF24 Toolbox.lnk" 2>nul
del /F /Q "%PUBLIC%\Desktop\PDF24 Launcher.lnk" 2>nul

echo removing a Startmenu icon ...
del /F /Q %STARTMENU%"\PDF24 Launcher.lnk" 2>nul

echo refreshing desktop (W10 style) ...
ie4uinit.exe -show

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

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

rem remove the FAX printer ...
call remove-printer.cmd "PDF24 Fax"

rem ... and remove the Microsoft fax printer ...
call remove-printer.cmd "Microsoft Print to PDF"

pause