Install Font

//Install Font
Install Font2015-10-28T21:14:10+00:00

The Toolkit Forums General Install Font

  • Author
  • Treeman
    Post count: 2

    Does anyone know how to install a .TTF font file?

  • Treeman
    Post count: 2

    I was able to get this installed with this command:

    $FONTS = 0x14
    $objShell = New-Object -ComObject Shell.Application
    $objFolder = $objShell.Namespace($FONTS)

  • Martureo
    Post count: 5

    Hi Gang,

    Thought i would recreate this thread as it pertains to both the install and uninstall of multiple font files via Shell ComObject Method.

    CONS : however there has been known issues where using Shell methods like this, fail to work on Remote and Build Agents because SHELL is not accessable when using those agents to execute your powershell script at : Avoid Using SHELL when using Remote or Build Agents

    I hope this code helps – I obtained the majority of this code at : Install Fonts via Command Line

    ## Add or Remove Font Files - only tested with TTF font files thus far
        # ADD or REMOVE MULTIPLE FONT FILES [Using ComObjects]
        # This code will install or uninstall a font using ComObject
        # You Must Modify the following variables in order to work
        # (A) $dirFiles                ==&gt;  This is the source folder path that contains all of your font files
        # (B) $InstallOrUninstall      ==&gt;  $true = Install Font ...  $false = UnInstall Font
            # Define Working Variables
                #$dirFiles = &quot;C:\Temp\Fonts&quot;
                $InstallOrUninstall = $true  # $true = Install  ...or...  $false = UnInstall
                $srcFontFiles = Get-ChildItem &quot;$($dirFiles)\Fonts&quot;
                $Fonts = (New-Object -ComObject Shell.Application).Namespace(0x14)
            # Copy each file into the Font Folder or Delete it - Depends on the $InstallOrUninstall variable setting
                ForEach($srcFontFile in $srcFontFiles) 
                    $srcFontFileName = $
                    $srcFontFileFullPath = $srcFontFile.fullname
                    $targFonts = &quot;C:\Windows\Fonts\$($srcFontFileName)&quot;
                    If ((Test-Path $targFonts -PathType any) -and ($InstallOrUninstall -eq $false)) { Remove-Item $targFonts -Recurse -Force } # UnInstall Font
                    If ((-not(Test-Path $targFonts -PathType container)) -and ($InstallOrUninstall -eq $true)) { $fonts.CopyHere($srcFontFileFullPath, 16) } # Install Font
    • This reply was modified 9 months ago by  Martureo.

You must be logged in to reply to this topic.