Skip to main content

Install a Font to the Windows Font Library


Tony-Automox

This worklet will add a TTF or OTF font to your Windows font library. Just upload the .ttf or .otf file to the worklet and set $font to the name of the uploaded font file in the evaluation and remediation.

Evaluation:

$font = "NAME_OF_FONT.ttf"

If (Test-Path "c:\windows\fonts\$($font)") { Exit 0 } else { Exit 1 }

Remediation:

$font = "NAME_OF_FONT.ttf"

    try {
        If (!(Test-Path "c:\windows\fonts\$($font)")) {
            switch (($font -split "\.")[-1]) {
                "TTF" {
                    $fn = "$(($font -split "\.")[0]) (TrueType)"
                    break
                }
                "OTF" {
                    $fn = "$(($font -split "\.")[0]) (OpenType)"
                    break
                }
            }
            Copy-Item $font -Destination "C:\Windows\Fonts\$font" -Force
            New-ItemProperty -Name $fn -Path "HKLM:\Software\Microsoft\Windows NT\CurrentVersion\Fonts" -PropertyType string -Value $font
        }
    }
    catch {
        write-warning $_.exception.message
    }

5 replies

Lantz
  • Novice
  • 8 replies
  • April 29, 2021

@Tony Thanks! This is awesome!


Forum|alt.badge.img
  • Novice
  • 28 replies
  • June 30, 2021

Hi @Tony,

Thanks for this worklet. I wonder if you have for MacOS version for installing font.

cc: @automoxsupport

Best,
Ulyssis


  • 0 replies
  • October 19, 2021

Thank you,

Tony, I need one more help. I have 20 other fonts, how can I add this to worklet.


  • 0 replies
  • October 28, 2021

Hello,

I need your help with when trying this I am getting WARNING: Cannot bind argument to parameter ‘Name’ because it is null.

$font = “‘EncodeSans-Black.ttf’,‘EncodeSans-Bold.ttf’,‘EncodeSansCondensed-Black.ttf’,‘EncodeSansCondensed-Bold.ttf’,‘EncodeSansCondensed-ExtraBold.ttf’,‘EncodeSansCondensed-ExtraLight.ttf’,‘EncodeSansCondensed-Light.ttf’,‘EncodeSansCondensed-Medium.ttf’
,‘EncodeSansCondensed-Regular.ttf’,‘EncodeSansCondensed-SemiBold.ttf’,‘EncodeSans-ExtraBold.ttf’,‘EncodeSans-ExtraLight.ttf’,‘EncodeSans-Light.ttf’,‘EncodeSans-Medium.ttf’,‘EncodeSans-Regular.ttf’,‘EncodeSans-SemiBold.ttf’,‘EncodeSans-Thin.ttf’”

try {
    If (!(Test-Path "c:\windows\fonts\$($font)")) {
        switch (($font -split "\.")[-1]) {
            "TTF" {
                $fn = "$(($font -split "\.")[0]) (TrueType)"
                break
            }
            "OTF" {
                $fn = "$(($font -split "\.")[0]) (OpenType)"
                break
            }
        }
        Copy-Item $font -Destination "C:\Windows\Fonts\$font" -Force
        New-ItemProperty -name $fn -Path "HKLM:\Software\Microsoft\Windows NT\CurrentVersion\Fonts" -PropertyType string -Value $font
    }
}
catch {
    write-warning $_.exception.message
}

if you can help that would be great.


Forum|alt.badge.img
  • Novice
  • 14 replies
  • March 31, 2023

Holy thread resurrection!

Don’t suppose anyone knows how to install multiple fonts in once script?


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings