Installing fonts with PDQD
Has anyone tried and/or found a way to push fonts to a workstation? I've tried to find a way to set group policy to allow non admin users to install fonts, but it's surprisingly complicated to do!
Since it's usually just one person here or there that needs the fonts, it would be nice to just be able to push the fonts one a per computer basis.
Create a script called "ADD_Fonts.cmd", from the code below, and put it in the same folder as the font files you want to be installed.
Create a new "install package" and point to the ADD_Fonts.cmd. Check "Include entire directory".
This is how I do it and it works fine here. :)
TITLE Adding Fonts..
REM Filename: ADD_Fonts.cmd
REM Script to ADD TrueType and OpenType Fonts for Windows
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=%*
REM 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 Done!
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
Thanks Emil :)
If I create a folder for a user and set it up as you instructed above so that the schedule runs once a day, that would allow the user to drop fonts into the folder as needed. That begs a question. Do you know what will happen when the script runs and how it will handle trying to install a font that already exists? I can set up a test machine but thought you may already know the answer. Thank you.
We could refactor her code into Powershell so we could add some error handling to allow for skipping duplicates.
I wouldn't know where to begin, as programming is outside of my expertise. I can always have her manually manage the folder, but if there is a way to deal with duplicates that would be so much easier.
Thats where I come in. Give me a minute. I'll post the Powershell alternative.
I will be watching for it and thank you in advance for your help with this matter. Very much appreciated.
Something like this should get you close:
EDIT: Added registry bit
Sorry that is poorly formatted. It's stripping off my line indents for some reason, so it kind of makes it hard to follow.
Thank you for setting this up. Is this copied to Notepad and saved as a .BAT file or something else?
Give me just one more second. I just re-read the file and it looks like the are using reg add to inject the registry with the font, which I didn't do in my script. I will add that step, and edit my post above with the new code. I will also be creating a secondary comment here shortly with a package xml that you can save as an xml file and import into your PDQ Deploy console so your package is all setup and ready to go. You'll just have to edit the Powershell step and change 'changeme' to the actual path you create for the user to dump fonts too.
Here is the XML to copy/paste into a new xml file and then Import:
You are amazing. Thank you again for taking the time to put this together. I'll give it a good test run and follow up here.
That would be good. I sort of tested it a little bit in chunks as I went, mostly to make sure I was putting the right data together, but I didn't test it in its entirety as a script or try to deploy it. Please let me know if you get any red text from the powershell, and post it here so I can have a look and fix it.
Will do. Have a great weekend.
Found a Alternative....
You need to use fontreg.exe /copy it will install all fonts within the directory and add a reg entry. (Reboot Required)
Thanks for the alternative. If I cannot get the solution provided by Stephen to work then I will try it.
I copied the script, pasted to Notepad, saved it as an XML, and imported it into PDQ Deploy. I changed the source and verified the path in Step 1. When deployed it failed with the status message, "Not Found - Failed to read file on source." I went back, verified the path, and verified permissions. The Deploy User has rights to the directory and the path is correct.
Is "Add-fonts.ps1" a pre-existing utility in PDQ Deploy or on the Windows server? It seems that it is being called from \\TUSCPDQ\PDQ\Powershell, and since that does not exist on our network I am guessing that is part if not all of the issue here. Will you let me know what I need to do here?
You'll want to change the Files to something other than TUSCPDQ. That's the name of my development box for staging changes to my PDQ environment.
You'll want to put it wherever you find easiest to get to. For me, in DEV, that is in the folder mentioned above, but is entirely different from your environment. Use the ... button to browse for and find your copy of Add-fonts.ps1. The field will update itself accordingly.
I edited my XML above to better reflect that for anyone else stumbling in here from a Google Search.
I guess I am not quite sure where the file "Add-fonts.ps1" comes from. I searched the PDQ Server and did not find it. Is that a file you sent to me and I have overlooked it?
You have to create it yourself from the Powershell code I posted above.
I figured out my confusion. I thought the first set of code you sent was replaced with the XML file. I now realize I need both. The first set of code is the Add-fonts.ps1 and the second was to facilitate the creation of the package in PDQ D. Sorry to be a tad slow on this.
Here is my font script for PDQ. It works great for Windows 10 & 7. I have a schedule set to install on any machines found in an AD group. The helpdesk then just has to add the machine in the group.
REG ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts" /v "Solitas Normal Book (OpenType)" /t REG_SZ /d "Solitas-NormBook.otf"
C:\Folder 1\Folder 2\
What I have Keep Here
Please sign in to leave a comment.