Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Is it possible to install fonts from the command prompt on Windows? If yes, what is the command?

I tried copy [fontname].ttf C:\Windows\Fonts\ and it said copying was complete, but I could neither find the said fonts in the Fonts folder nor find them in the font list of any program so that certainly didn't work. (Although I was able to delete the said fonts from the Fonts folder afterwards)

share|improve this question
    
Related: stackoverflow.com/questions/28687666/… –  Jerry Dodge Feb 24 at 15:07

6 Answers 6

It's possible but you have to write a Windows shell script to do that. Copying alone won't install the font: you also need to register the font, e.g.

copy "FontName.ttf" "%WINDIR%\Fonts"
reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts" /v "FontName (TrueType)" /t REG_SZ /d FontName.ttf /f

Alternatively you can the following lines of code to suit your needs; save it as a .vbs file and then execute it.

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace("<Folder or Share Location>")
Set objFolderItem = objFolder.ParseName("<TTF File Name>")
objFolderItem.InvokeVerb("Install")

Example:

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace("C:\Windows\Font")
Set objFolderItem = objFolder.ParseName("Myriad Pro.ttf")
objFolderItem.InvokeVerb("Install")

Yet another alternative is to install fonts "temporary", just for current user session. The idea is to run fontview.exe for each font, which makes it available for other Windows applications:

for /F "delims=;" %%a in ('dir C:\ExtraFonts /B /A-D-H-S /S') do fontview %%a

See the complete solution here.

share|improve this answer
    
Will you be so kind to extend your script to: (1) Automatically install all *.ttf and *.fon fonts from current directory (2) Use Const FONTS = &H14& as suggested here (sevenforums.com/general-discussion/…). I am not king on VBS :( Thanks in advance. –  dma_k Aug 17 '11 at 13:09
    
objFolderItem.InvokeVerb("Install") does not work on Windows Server 2012 R2 –  Anthony Kong Nov 10 '14 at 22:57

In Powershell this can be as simple as:

$fonts = (New-Object -ComObject Shell.Application).Namespace(0x14)
dir fonts/*.ttf | %{ $fonts.CopyHere($_.fullname) }
share|improve this answer
    
great answer, thx –  majkinetor May 14 at 11:25

Similar to GeneQ's solution, here is a version doing it for all .ttf files in the script's directory:

Set ofso = CreateObject("Scripting.FileSystemObject")
SourceFolder = ofso.GetParentFolderName(Wscript.ScriptFullName)

Const FONTS = &H14&

Set objShell  = CreateObject("Shell.Application")
Set oSource   = objShell.Namespace(SourceFolder)
Set oWinFonts = objShell.Namespace(FONTS)

' Lame VBscript needs 4 f*ing lines instead of "if (/\.ttf$/i) " ...
Set rxTTF = New RegExp
rxTTF.IgnoreCase = True
rxTTF.Pattern = "\.ttf$"

FOR EACH FontFile IN oSource.Items()
    IF rxTTF.Test(FontFile.Path) THEN   
        oWinFonts.CopyHere FontFile.Path
    END IF
NEXT
share|improve this answer

You can also use the FontReg utility to install fonts from a command prompt.

share|improve this answer

Create a script file called InstallFonts.vbs in my case I put it in C:\PortableApps\InstallFonts\ IN the below code replace "SomeUser" with the username of the person you want to be able to install fonts. Then make the Appropriate "install Fonts" folder on their desktop.

    Set ofso = CreateObject("Scripting.FileSystemObject")
'SourceFolder = ofso.GetParentFolderName(Wscript.ScriptFullName)
SourceFolder = "C:\Users\SomeUser\Desktop\Install Fonts"


Const FONTS = &H14&

Set objShell  = CreateObject("Shell.Application")
Set oSource   = objShell.Namespace(SourceFolder)
Set oWinFonts = objShell.Namespace(FONTS)

' Lame VBscript needs 4 f*ing lines instead of "if (/\.ttf$/i) " ...
Set rxTTF = New RegExp
rxTTF.IgnoreCase = True
rxTTF.Pattern = "\.ttf$"

FOR EACH FontFile IN oSource.Items()
    IF rxTTF.Test(FontFile.Path) THEN   
        oWinFonts.CopyHere FontFile.Path
    END IF
NEXT

Now create a shortcut on their desktop that is as follows...

C:\Windows\System32\runas.exe /user:Administrator /savecred "wscript C:\PortableApps\InstallFonts\InstallFonts.vbs"

Note that I used "Administrator". I enabled it and assigned it a password. I suppose you could use any administrator account for this. First time you run the shortcut you will be prompted for the administrator password.. every time after it will just work.

If it does not prompt you for a password run the shortcut from a cmd prompt it should prompt you then.

I cannot promise you how secure this is as in if they could use it to run elevated code. However it is a solution.

share|improve this answer

You didn't list your Windows version, but I assume you're running Vista or 7. Copying to that directory requires administrative privileges. Try what you did again, but use an Elevated Command Prompt instad this time.

share|improve this answer
2  
He said that the copy succeeded. If permissions were preventing him from successfully copying there, it would have told him that the copy failed, so this probably isn't the problem. –  nhinkle Dec 21 '10 at 21:33

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.