Jump to content

[Unsolved] Install Fonts by Right clicking


spacesurfer

Recommended Posts

By adding an action called "Install" (from File Types tab) to the TTF file types, I was able to install 1 font. I got the "Install" right-click context menu item to link to a cmd file called install_font.cmd, which contained the line

copy %1 "%windir%\fonts"

The "Install" action runs the following command:

"%windir%\install_font.cmd" "%1"

and DDE is checked.

However, it only install 1 font. When multiple fonts are selected, it does not work.

I tried changing %1 to %L but that doesn't work.

Anyone know how I can install all selected fonts to install.

Edited by spacesurfer
Link to comment
Share on other sites


How to install many fonts quickly.

Open a cmd prompt and type:

for %a in ( *.ttf ) do copy %a %windir%\fonts

Maybe you should add an action "Command Prompt Here" instead... very useful.

Link to comment
Share on other sites

How to install many fonts quickly.

Open a cmd prompt and type:

for %a in ( *.ttf ) do copy %a %windir%\fonts

The idea here is to be able to select say 10 of 50 fonts and install those with one click. Opening command prompt defeats that purpose. I already have it installed.

Thanks for idea though.

Link to comment
Share on other sites

In Windows 2000, unchecking DDE works. You can install only the selected, multiple fonts with one click.

However, in Win XP, it doesn't allow you to uncheck DDE. Although you can uncheck it, when you go back to TTF props, it is selected again.

Any other suggestions?

What is DDE, anyway?

Link to comment
Share on other sites

DDE = Dynamic Data Exchange

i don't know anything more about that, except that it's meant for "regular" win32 applications, not for batches.

I tested again, and all seems ok, even if the box comes back checked. You should have these DDE fields :

[x] use DDE

Message :

Application : install_font

Inactive App :

"rubrique" (doesn't know its translation) : System

Now, edit install_font.cmd :

@echo off
echo.
echo Install font file : %1
echo.
copy /y "%1" "%systemroot%\fonts"
echo.
pause

Then select 5 fonts and install them. you'll see five console boxes, with five successful copy operations.

Now, go to windows\fonts with explorer. Your fonts aren't there. That is because explorer doesn't display the real contents of the fonts folder, but only the registered fonts, in the reg key HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts.

Open a cmd prompt and CD %windir%\fonts, then DIR to see : your fonts are there.

To see your fonts in explorer (and in other apps too), you need to refresh the font cache, either with F5 in explorer (or menu View > refresh), either by creating the reg entry, either by rebooting (or maybe relogging).

Another method is to use fontinst.exe (a little MS executable that creates the reg entries) :

1. google for "microsoft core fonts for the web" : you'll end up on a sourceforge site, and D/L the andale32.exe archive : fontinst.exe is in there

2. copy fontinst.exe to system32

3. use this install_font.cmd script :

@echo off
setlocal enableextensions
MD "%TEMP%\FNT.TMP"
FOR %%a IN (%*) DO IF EXIST %%a CALL :INST %%~dpnxa
CD /D %TEMP%
RD /Q/S FNT.TMP
GOTO :EOF

:INST
TITLE Installing font %1...
COPY /Y "%1" "%TEMP%\FNT.TMP"
ECHO [fonts]>"%TEMP%\FNT.TMP\fontinst.inf"
DIR /A/B "%TEMP%\FNT.TMP\*.TTF">>"%TEMP%\FNT.TMP\fontinst.inf"
MOVE /Y "%systemroot%\system32\fontinst.exe" "%TEMP%\FNT.TMP"
START /WAIT "%TEMP%\FNT.TMP\fontinst.exe"
MOVE /Y "%TEMP%\FNT.TMP\fontinst.exe" "%systemroot%\system32"
GOTO :EOF

note : fontinst.exe will fail if a font of the same name and of a higher version is already installed (if version is lower, it will replace it) ; it will fail if it can't read the font name in the TTF file.

++

Edited by Delprat
Link to comment
Share on other sites

Thanks a whole bunch, Delprat.

That did it.

I don't know if it's the /y switch or the quotes around %1 that did it, but it works now.

I also got rid of the pause at the end, I don't need a confirmation after installation.

What does the /y switch do?

Thanks a whole lot!

Link to comment
Share on other sites

maybe i spoke to soon.

it works on my work computer but not on my laptop!!

that's just weird. everything is the same. I copied the working cmd file from my work computer and exported the registry keys on my laptop but didn't work.

I tried typing everything myself but that didn't work either.

both are sp2.

this is nuts.

Link to comment
Share on other sites

[s]Finally! Figured it out!! No need for fontinst.exe. I played around with it, then I realized all I have to do is create the following in my install_fonts.cmd file:

FOR %%a IN (%*) DO IF EXIST %%a CALL :INST %%~dpnxa
GOTO :EOF

:INST
COPY /Y "%1" "%systemroot%\fonts"
:EOF

Then, make an Install action for right click that points to install_fonts.cmd.

Done.

Essentially, all you are accomplishing with the fontinst.exe is to copy the file to the fonts folder.

Since, when your in windows, copying font file to font folder is the same as installing, you don't have to mess with registering fonts.

Nevermind, it works for only one selected font file, not multiple files.

Delprat, I even tried fontinst and the script you provided. It does not work for multiple fonts selected, only for 1 selected file.

Any ideas why?

Edited by spacesurfer
Link to comment
Share on other sites

If your fonts have spaces, such as "Tattoo Ink.ttf", then you may want to use this script instead:

FOR %%a IN (%*) DO IF EXIST %%a CALL :INST "%%~dpnxa"
GOTO :EOF
:INST
COPY /Y %1 "%systemroot%\fonts"
:EOF
pause

Otherwise, it will not work with font filenames that have spaces.

Basically, the quotes are around "%%~dpnxa" instead of %1. This prevents the font path from being cut off as in "h:\fonts\Tattoo" rather than "h:\fonts\Tattoo Ink.ttf"

Link to comment
Share on other sites

Ok, stupid bug from me :(

In the code you tried to use, the %1 in the :INST section should be %*.

Or you can replace %~dpnxa by %~fsnxa : it will return short pathes (here was my mistake).

You last code look bad. All this "CALL :INST" stuff isn't needed if you don't want to use fontinst.exe ! A single line will be enough :

for %%a in (%*) do if exist %%~fsnxa copy /y %%~fsnxa "%systemroot%\fonts"

(there's no quotes aound %%~fsnxa since it's short path/name, if you use %%~dpnxa, add quotes)

I'd bet this single line can go directly in the file association box (you may need to play a bit with quotes to get it working) :

%systemroot%\system32\cmd.exe /e:on /s /c "for %%a in ("%1") do if exist %%~fsnxa copy /y %%~fsnxa %systemroot%\fonts"

Anyway, even if it seems to be working, this sort of code without fontinst.exe is buggy. Imagine you have one installed font named "Verdana (TrueType)" with filename "VERDANA.TTF". You try to install a file named "VERD___.TTF" containing a font named "Verdana (TrueType)". With a simple copy operation, you'll end up with two Verdana files, and in fact only one used (but which ?). With fontinst.exe, this will not happen (the new font file will be installed only if newer)...

And how a simple "copy" would handle variations (that is bold/italic/bold italic, sometimes in different files, sometimes in one single file) ?

++

Link to comment
Share on other sites

@Delprat

Let me explain what happens.

First, all of your methods work on Windows 2000 - both the simple copy and using fontinst.exe. I tried both on Windows 2000 and it works flawlessly.

However, on a Windows XP machine (my laptop with post-sp2 hotfixes using RyanVm pack and wmp10 addon) - this does not work completely.

On Windows XP, this works for only 1 selected font. However, when you select 2 or more fonts, it doesn't work. There's no activity at all. The command prompt windows does not even show up. When selecting 1, you can tell it's copying because you see the command prompt windows open and close. But for more than two, nothing.

I'm not sure why this is so?? I tried changing the compatibility mode of the script to Windows 2000 and that didn't work either.

Oh! well. I guess it's too good to be true.

(Also, I agree about the fontinst.exe method. However, same problem - selecting more than two does not work. It works only with 1 font selected). If I can get it to work, I'd use the fontinst.exe method.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...