Installing System Font with Powershell

前端 未结 4 1242
悲哀的现实
悲哀的现实 2021-02-07 23:51

I have a folder filled with TTF files of custom fonts. I need to install them as system fonts using a powershell script (this is on Windows Server 2008 R2). Does anybody know

4条回答
  •  遥遥无期
    2021-02-08 00:18

    Just wanted to post an alternative which doesn't require 0x14 to be hard coded into the script. Pass the file object to the function, and it will just run the "Install" based on where the file is:

    Function Install-Font {
       Param (
          [Parameter(Mandatory=$true,ValueFromPipeline=$true)][System.IO.FileSystemInfo[]]$File
       )
       $shell = New-Object -ComObject Shell.Application
       $File | % {
          $Fonts = $shell.NameSpace($_.Directory.Name)
          $font = $Fonts.ParseName($_.Name)
          $font.InvokeVerb("Install")
       }
    }
    

提交回复
热议问题