I needed a way to automate the distribution of fonts (TrueType) fonts via a script. I was surprised to discover that it's not as easy as just copying the font files to the %windir%\fonts folder. Searching around on the Internet, I see that it's not so uncommon to want to be able to do this, but surprisingly, I found no free solution for accomplishing this task - and the programmatic way is over my head.
Typically, to install and register a new Windows font, you have to use Explorer, browse to the Windows Fonts directory, then use the Install New Font... menu item.
However, I discovered something interesting. You can just copy the TTF files from DOS into the font directory (%windir%\fonts), then if you open explorer to the fonts directory the new fonts will automatically get registered. So, this could be scripted like this:
copy *.TTF %Windir%\fonts /y
explorer /e, %Windir%\fonts
And the fonts would successfully be added to the system. However, it isn't exactly silent. The user is left with a Windows Explorer window open that they would need to then close.
I wanted a more silent way to do this. Same concept, except I launch explorer in a hidden window (using my RunHide program), then kill the process silently. Thus, you can silently add new fonts programmatically by:
copy *.TTF %Windir%\fonts
copy %windir%\explorer.exe %temp%\xpl.exe /y
runhide %temp%\xpl.exe /e,%windir%\fonts
ping localhost -n 5 >nul
taskkill /im xpl.exe /f
Kludgy, but it'll work and without any user interaction (or notice).
- The "ping" line causes a 5 second delay, time for explorer to launch
- You will need to have Explorer configured to launch as a separate process for this solution to work:
Disclaimer: As with everything else at Cool Solutions, this content is definitely not supported by Novell (so don't even think of calling Support if you try something and it blows up).
It was contributed by a community member and is published "as is." It seems to have worked for at least one person, and might work for you. But please be sure to test, test, test before you do anything drastic with it.