通过GPO推送字体

一个常被问到的问题,但标准的解决scheme似乎并不适合我。

我有一个主要Windows 7客户端的Windows Server 2012 R2的AD。 我有一个GPO,执行以下操作:

计算机configuration\首选项\ Windows设置\文件:

Action: Update Source: <Network drive domain computers have read access to>\fonts\* Destination: %WindowsDir%\Fonts 

然后我也单独更新每个字体的registry:

 Action: Update Hive: HKLM Value name: <fontname> <(TrueType)|(OpenType)> Value type: REG_SZ Value data: <font file name> 

当我做gpupdate ,registry的变化得到部署,但字体永远不会到达字体文件夹。 这不是一个访问问题,因为当我将目的地更改为我的桌面时,所有的字体出现。 我也可以从那里手动安装它们。

我试过了:

  • 将操作更改为CREATE或REPLACE
  • 使用目标的完整path而不是%WindowsDir%
  • 使用源代码的完整path(所以没有通配符)
  • 重新启动目标机器

他们只是从来没有被复制到字体文件夹。 有没有办法做到这一点,而不创build一个MSI?

有很多方法可以解决这个问题。 就我个人而言,我发现字体文件的“安装”动词/动作是最可靠的。 这可以在Powershell或VBS中用SYSTEM计划任务轻松完成。

我使用这个变化来做一个文件夹中的所有字体。

 $path = "\\font-server\Fonts" $shell = New-Object -ComObject Shell.Application $shell.Namespace($path).Items().InvokeVerbEx("Install") 

蒂姆 – 布里格姆(Tim-Brigham)有正确的想法,但稍微复杂一些。

首先,创build一个networking共享域计算机已经读取访问。 由于您将从此共享中调用具有系统特权的脚本,因此重要的是他们只能阅读。

在这个networking共享上,还可以创build一个包含所有你喜欢的字体的文件夹。

然后在networking文件夹中创build这个脚本:

 $path = "<path to font folder on network share>" $shell = New-Object -ComObject Shell.Application $fonts = $shell.Namespace($path).Items() # check if font already exists in windows font folder, if not, install foreach($font in $fonts) { $sourcepath = $font.path $filename = Split-Path -Leaf $sourcepath $destinationpath = 'C:\Windows\fonts\' + $filename if (![System.IO.File]::Exists($destinationpath)) { $font.InvokeVerbEx("Install") } } 

接下来,为每个GPO创build一个计划任务:

 Computer Configuration -> Preferences -> Control Panel Settings -> Scheduled Task Action: Update Use the following User Account: S-1-5-18 Run with highest privileges Triggers: At logon Actions: Start a program: powershell.exe -NonInteractive -WindowStyle Hidden -ExecutionPolicy bypass -File <scriptpath> 

在这里使用用户帐号S-1-5-18是非常重要的,这是NT-Authority / SYSTEM,但是如果你使用文字NT-Authority / SYSTEM,用户映射将不起作用。

用户需要注销两次。 一次安装字体,但字体caching不刷新,直到login。