@echo off
title Chibur for Word
echo Adding Chibur to Word...
set "D=%APPDATA%\Chibur\Word"
if not exist "%D%" mkdir "%D%"
powershell -NoProfile -ExecutionPolicy Bypass -Command "Invoke-WebRequest -UseBasicParsing -Uri 'https://yakai.biz/word/manifest.xml' -OutFile '%D%\manifest.xml'"
if not exist "%D%\manifest.xml" (echo Could not download the manifest. Check the internet connection and try again. & pause & exit /b 1)
powershell -NoProfile -ExecutionPolicy Bypass -Command "Invoke-WebRequest -UseBasicParsing -Uri 'https://yakai.biz/word/manifest-gilyon.xml' -OutFile '%D%\manifest-gilyon.xml'"
reg add "HKCU\Software\Microsoft\Office\16.0\WEF\Developer" /v "6f3c2a51-9d8e-4b7a-a1c2-c41b0f2e7d38" /t REG_SZ /d "%D%\manifest.xml" /f >nul
set "K=HKCU\Software\Microsoft\Office\16.0\WEF\TrustedCatalogs\{8C2B6E3A-1F4D-4C7A-9E21-C41B0F2E7D38}"
reg add "%K%" /v Id /t REG_SZ /d "{8C2B6E3A-1F4D-4C7A-9E21-C41B0F2E7D38}" /f >nul
reg add "%K%" /v Url /t REG_SZ /d "\\%COMPUTERNAME%\ChiburWord" /f >nul
reg add "%K%" /v Flags /t REG_DWORD /d 1 /f >nul
echo Windows will ask once to allow sharing the Chibur folder (read-only, for your account only)...
> "%D%\share.cmd" echo @echo off
>> "%D%\share.cmd" echo net share ChiburWord /delete ^>nul 2^>^&1
>> "%D%\share.cmd" echo net share ChiburWord="%D%" /grant:%USERNAME%,READ
powershell -NoProfile -Command "Start-Process -FilePath '%D%\share.cmd' -Verb RunAs -Wait"
echo.
echo Done. Close every Word window, wait a few seconds and open Word.
echo Then in Word: Home (or Insert) - Add-ins - SHARED FOLDER - add "Chibur" (sefarim) and / or "Chibur Gilyon" (a weekly gilyon).
tasklist /FI "IMAGENAME eq WINWORD.EXE" 2>nul | find /I "WINWORD.EXE" >nul && (echo. & echo Word is still running. Save your work, close every Word window, and wait a few seconds before opening Word. & echo If the tabs still do not show, restart the computer.)
pause
