Share via


Can no longer install fonts via script in Windows 10 1809

Question

Friday, November 23, 2018 7:19 AM

Hi all,

we have started testing Windows 1809 (the re-released version from November 18 of course) and discovered an issue with installing fonts via script.

For years I have used this little VBscript to install true type fonts that are in the current folder where the script resides

Set ofso = CreateObject("Scripting.FileSystemObject")
SourceFolder = ofso.GetParentFolderName(Wscript.ScriptFullName)

Const FONTS = &H14&

Set objShell  = CreateObject("Shell.Application")
Set oSource   = objShell.Namespace(SourceFolder)
Set oWinFonts = objShell.Namespace(FONTS)

Set rxTTF = New RegExp
rxTTF.IgnoreCase = True
rxTTF.Pattern = "\ttf$"

FOR EACH FontFile IN oSource.Items()
     IF rxTTF.Test(FontFile.Path) THEN  
         oWinFonts.CopyHere FontFile.Path
     END IF
NEXT

This worked flawlessly for years and with all Windows 10 editions including 1803. Now in 1809 the script does not work any more. What I have found out so far is, that in 1809 the script tries to install the fonts inside the userprofile of the user where it is running from.

I discovered that in 1809 there is a new option that allows users to install fonts.

The script above will now always install these fonts in a folder of the current user and registers them in the HKCU, no longer in HKLM (although the script is being run with administrative permissions). IT seems that the default behavior to install fonts has changed in 1809 from admin to user.

Big question: How can I install fonts (systemwide with admin permissions) through a script? Manual installation via GUI works fine, but I need a scripting solution.

What a big mess with 1809 ...

Thanks for helping out

Regards

Udo

All replies (10)

Monday, November 26, 2018 6:49 AM

Hi Udo, 

I noticed the font installation through GUI works well but not through a scirpt. So I recommend to ask for help from Script Forum. 

Script Forum link:

https://social.technet.microsoft.com/Forums/en-US/home?category=scripting

The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. 

Thank you for your understanding!

Bests, 

Please remember to mark the replies as answers if they help.
If you have feedback for TechNet Subscriber Support, contact [email protected].


Monday, December 3, 2018 4:24 PM

Have you gotten anywhere on this?

Thank you,

Adam


Friday, December 21, 2018 8:06 PM

I too am struggling with this and haven't come up with a good solution.


Wednesday, January 9, 2019 2:08 PM

Any update to this issue?


Friday, January 25, 2019 3:00 PM

This might have something to do with this:

https://blogs.windows.com/windowsexperience/2018/06/27/announcing-windows-10-insider-preview-build-17704/#M3v00vw2VcehQM4E.97

Font installation for non-admin users


Wednesday, February 13, 2019 2:06 PM

Hello still no solution for this problem?

I also had several vbs script to install fonts. On build 1809 no script is installing the fonts in c:\windows\fonts.

I also used a powershell script but this has the same outcome.

Regards,

Ron.


Tuesday, February 19, 2019 3:01 AM | 2 votes

To workaround this, you can install fonts for all users by copying the .ttf files to c:\windows\fonts, and then add a registry entry for each ttf file, as follows:

 

Windows Registry Editor Version 5.00

 

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts]

"DIN OT Bold (TrueType)"="DINOT-Bold.ttf"

"DIN OT Bold Italic (TrueType)"="DINOT-BoldItalic.ttf"

"DIN OT Italic (TrueType)"="DINOT-Italic.ttf"

"DIN OT Light (TrueType)"="DINOT-Light.ttf"

"DIN OT Light Italic (TrueType)"="DINOT-LightItalic.ttf"

"DIN OT Medium (TrueType)"="DINOT-Medium.ttf"

"DIN OT Medium Italic (TrueType)"="DINOT-MediumItalic.ttf"

"DIN OT (TrueType)"="DINOT.ttf"

You can get the names from a 1709 machine where the script previously worked.

Hope this helps.  


Monday, February 25, 2019 9:29 AM | 1 vote

Hi,

I just fixed my TS With this:

Commandline in TS:

%SCRIPTROOT%\nircmd.exe elevate \Server\d$\MDTBuildLab\Fonter\addfonts.cmd [\server\d$\MDTBuildLab\Fonter\fonts\](file://\server\d$\MDTBuildLab\Fonter\fonts)

The Script:

@ECHO OFF
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.
REM ECHO Adding Fonts..
REM ECHO.
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.
REM ECHO Done!
REM PAUSE
EXIT
EXIT

:FONT
ECHO.
REM ECHO FILE=%~f1
SET FFILE=%~n1%~x1
SET FNAME=%~n1
SET FNAME=%FNAME:-= %
IF "%~x1"==".otf" SET FTYPE=(OpenType)
IF "%~x1"==".ttf" SET FTYPE=(TrueType)

ECHO FILE=%FFILE%
ECHO NAME=%FNAME%
ECHO TYPE=%FTYPE%

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
GOTO :EOF


Thursday, August 22, 2019 2:50 PM

Try this:

<#  Install-Fonts 3.0
    Place Fonts in the 'Fonts' subfolder of the script folder
    
      *** CURRENTLY ONLY SUPPORTS ***
    TrueType FONTS (.TTF EXTENSION)
    
    Script uses the extended file attributes "Title" and "Type" to create the required registry key
    -Details on finding extended file attibutes are here: https://stackoverflow.com/questions/9420055/enumerate-file-properties-in-powershell
    -And here for more details: http://web.archive.org/web/20160201231836/http://powershell.com/cs/blogs/tobias/archive/2011/01/07/organizing-videos-and-music.aspx
    Script uses the extended file attribute "Type" to determine font type and sets the $FontType Variable
    -Note this currently requires coding to add additional font types.
    The string ' (TrueType)' is appended to the file "Title" to properly format the registry key
    A reboot is required for the added Font(s) to be available
    Peter McDaniel, Olenick and Associates, 08.12.2019
#>

$Shell = New-Object -COMObject Shell.Application
$FONTS = "C:\Windows\Fonts"
ForEach($File in $(Get-ChildItem -Path ".\fonts")){
    If (Test-Path "C:\Windows\Fonts\($File.name)")
    { }
    Else
    {
$Path = $File.FullName
$Folder = Split-Path $Path
$File = Split-Path $Path -Leaf
$ShellFolder = $Shell.Namespace($Folder)
$ShellFile = $ShellFolder.ParseName($File)
$ExtAtt2 = $ShellFolder.GetDetailsOf($ShellFile, 2)

#Set the $FontType Variable
  If ($ExtAtt2 -Like '*TrueType font file*') {$FontType = '(TrueType)'}

$ExtAtt21 = $ShellFolder.GetDetailsOf($ShellFile, 21) + ' ' + $FontType
New-ItemProperty -Name $ExtAtt21 -Path "HKLM:\Software\Microsoft\Windows NT\CurrentVersion\Fonts" -PropertyType string -Value $File -Force
Copy-item $Path -Destination $FONTS
    }
}


Monday, September 23, 2019 12:18 PM

Hi Peter,

Is there a way to adapt this script to make it point to a specific folder on a file share instead of having the fonts in a sub-directory of the script?

Many thanks,

Russell