@echo off
rem SmartEPMO tab for Excel: installs the SmartEPMO add-in for this Windows user.
rem It saves the add-in's manifest from https://smartepmo.com/excel-addin/manifest.xml
rem under your own profile and lists it for Excel. Nothing else is changed.
rem Run it again with /remove to take the tab off.
setlocal
set "ID=3910dd62-16c1-4142-b00c-83b71a806a6f"
set "DIR=%LOCALAPPDATA%\SmartEPMO\excel-addin"
set "KEY=HKCU\Software\Microsoft\Office\16.0\WEF\Developer"
if /i "%~1"=="/remove" (
  reg delete "%KEY%" /v "%ID%" /f >nul 2>&1
  echo The SmartEPMO tab is removed. Close every Excel window and open Excel again.
  pause
  exit /b 0
)
if not exist "%DIR%" mkdir "%DIR%"
curl.exe -fsSL "https://smartepmo.com/excel-addin/manifest.xml" -o "%DIR%\manifest.xml"
if errorlevel 1 (
  echo Could not download the add-in. Check the internet connection and try again.
  pause
  exit /b 1
)
findstr /c:"%ID%" "%DIR%\manifest.xml" >nul
if errorlevel 1 (
  echo The downloaded file is not the SmartEPMO add-in. Nothing was installed.
  pause
  exit /b 1
)
reg add "%KEY%" /v "%ID%" /t REG_SZ /d "%DIR%\manifest.xml" /f >nul
echo SmartEPMO is installed for Excel.
echo  1. Close every Excel window and open Excel again.
echo  2. The first time, open it from Home ^> Add-ins ^> SmartEPMO. The tab stays from then on.
pause
