用命令行为所有用户安装字体

把 ttf/otf 字体复制进 C:\Windows\Fonts 并写入注册表,让所有账号和所有软件(如 PS、Office)都能用,不用右键安装。

Windows字体注册表文件中风险
把字体文件复制到 %windir%\Fonts,然后在 HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts 下新建一个名为"字体名 (TrueType)"、数值数据为文件名的 REG_SZ 值。

01命令

命令
$ copy "C:\Downloads\MyFont.ttf" "%windir%\Fonts\" && reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts" /v "MyFont (TrueType)" /t REG_SZ /d "MyFont.ttf" /f

02作用说明

右键字体选"安装"只对当前用户生效,而"为所有用户安装"实际做的就是这两步:把文件放进系统 Fonts 文件夹,再在注册表 Fonts 键下登记一条记录告诉系统有这个字体。注册表值的名称要按字体类型写,ttf 用"(TrueType)",otf 用"(OpenType)",数值数据只填文件名不填路径。之后重启需要用字体的软件即可识别;个别老软件看不到时重启电脑。

03风险

风险中风险
使用条件Run Command Prompt as administrator. Replace both file names and the registry value text with your font's real names.
!注意: 命令里的 MyFont 必须换成你字体的真实文件名和显示名,两处不一致字体就不会显示。写 HKLM 注册表需要管理员权限。

04撤销

撤销
$ reg delete "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts" /v "MyFont (TrueType)" /f && del "%windir%\Fonts\MyFont.ttf"

05来源

  • AddFontResourceA function (wingdi.h)
    Microsoft Learn · vendor-doc · 2026-09-17
    依据: Documents how the system makes a font available: the font file must be placed in the Windows Fonts directory and registered under HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts.
  • reg - SS64
    SS64 · technical · 2026-09-17
    依据: Reference for reg add / reg delete syntax used to create and remove the font registry value.

最后验证: 2026-09-18 · 分类: 系统与设置

06相关方案