|TITLE Adding Fonts..|
|REM Filename: ADD_Fonts.cmd|
|REM Script to ADD TrueType and OpenType Fonts for Windows|
|REM By Islam Adel|
|REM How to use:|
|REM Place the batch file inside the folder of the font files OR:|
|REM Optional Add source folder as parameter with ending backslash and dont use quotes, spaces are allowed|
|REM example "ADD_fonts.cmd" C:\Folder 1\Folder 2\|
|IF NOT "%*"=="" SET SRC=%*|
|ECHO Adding Fonts..|
|FOR /F %%i in ('dir /b "%SRC%*.*tf"') DO CALL :FONT %%i|
|REM OPTIONAL REBOOT|
|REM shutdown -r -f -t 10 -c "Reboot required for Fonts installation"|
|REM ECHO FILE=%~f1|
|SET FNAME=%FNAME:-= %|
|IF "%~x1"==".otf" SET FTYPE=(OpenType)|
|IF "%~x1"==".ttf" SET FTYPE=(TrueType)|
|COPY /Y "%SRC%%~n1%~x1" "%SystemRoot%\Fonts\"|
|reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts" /v "%FNAME% %FTYPE%" /t REG_SZ /d "%FFILE%" /f|
Great script! The only problem is that it doesn't work for font files with spaces in them. I have altered line 19 to fix it.
FOR /F "tokens=" %%i in ('dir /b "%SRC%.*tf"') DO CALL :FONT "%%i"
Seems to work well. Still doesn't work with characters such as "&" but I've just renamed those files as a workaround.
I spent a lot of time to find a way for installing font without restart. Finally I found this ClickFont. It's an easy and exact solution :)