Announcement

Collapse
No announcement yet.

Script to add fonts to XP

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Script to add fonts to XP

    Stole, borrowed and modified the following script to copy fonts to an XP SP2 PC running Office 2007. The script copies the fonts from and to the correct locations mentioned and adds the appropriate entries to the appropriate Registry Key. Fonts can be double clicked on in the Fonts folder and they display correctly.

    Problem is that they do NOT appear in the font pull down menu in Office (Word, Excel or PowerPoint). For this to happen (using this script), the PC has to be rebooted and logged on with an Administrator account. (Logging off and back on with an Admin account doesn't work) After the reboot and logon, you can logoff and then back on using a User account and the fonts are available in Office.

    Is there any way to modify this script so the Admin account reboot part is not necessary and the fonts will be available without it?


    Code:
    dim wsh,fso,fontfolder,destination
    set wsh=wscript.createobject("wscript.shell")
    set fso=wscript.createobject("scripting.filesystemobject")
    
    fontfolder = "\\server\netlogon\fonts\"
    destination = "c:\windows\fonts\"
    
    wsh.regwrite "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Fonts\Vic Cursive with Line (TrueType)", "VicCurLine.ttf"
    wsh.regwrite "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Fonts\Vic Dot with Line (TrueType)", "VicDotLine.ttf"
    wsh.regwrite "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Fonts\Vic Modern Cursive (TrueType)", "VicModCur.ttf"
    wsh.regwrite "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Fonts\Vic Speed Loop (TrueType)", "VicSpeed.ttf"
    wsh.regwrite "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Fonts\Vic Cursive Dottted (TrueType)", "vmc_dot.ttf"
    wsh.regwrite "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Fonts\Vic Mod Cur Joined Normal (TrueType)", "vmc_join.ttf"
    
    
    'wscript.echo fontfolder & "VicCurLine.ttf" & destination
    fso.copyfile fontfolder & "VicCurLine.ttf", destination
    fso.copyfile fontfolder & "VicDotLine.ttf", destination 
    fso.copyfile fontfolder & "VicModCur.ttf", destination 
    fso.copyfile fontfolder & "VicSpeed.ttf", destination 
    fso.copyfile fontfolder & "vmc_dot.ttf", destination 
    fso.copyfile fontfolder & "vmc_join.ttf", destination
    Thanks.
    1 1 was a racehorse.
    2 2 was 1 2.
    1 1 1 1 race 1 day,
    2 2 1 1 2

  • #2
    Re: Script to add fonts to XP

    This is because the GUI also sends a notification message to the shell to refresh the font cache.

    http://www.microsoft.com/technet/scr...8/hey0425.mspx
    Guy Teverovsky
    "Smith & Wesson - the original point and click interface"

    Comment


    • #3
      Re: Script to add fonts to XP

      Biggles77's script can work too.
      It is the fact that normal users are not allowed to edit HKLM\ and to edit windowsfolders. Therefor you can't run your script as logon script, you must run it as computer startup script.
      And one other thing is the variable name wsh you are using for the object wscript.Shell. WSH is a reserved name for "wscript" you can not use that name for something else. (replace all instance of that name in your script to objWshShell, and run the script during start up and it should work)

      I used this method once, but not by using vbscript. I snapshot a fresh install of Windows. Then installed all True Type and type1 fonts on the computer. With a second snapshot afterwards I was able to create a msi installation package.


      If you want to install only a few sets of fonts, the solution Guy did linked to is much easier (this script can also used for installing type1 fonts - then copyhere the *.pfm files while the pre-generated *.PFB must be present in the source folder).

      note: This script must also run as Startup script.
      Code:
      Const FONTS = &H14&
      
      fontpath = "\\server\netlogon\fonts"
      
      arrFonts = ARRAY(_
         "VicCurLine.ttf", _
         "VicDotLine.ttf", _
         "VicModCur.ttf", _ 
         "VicSpeed.ttf", _ 
         "vmc_dot.ttf", _ 
         "vmc_join.ttf" )
      
      Set objShell = CreateObject("Shell.Application")
      
      Set objFolder = objShell.Namespace(FONTS)
      Set objFolderItem = objFolder.Self
      sDestinationPath = objFolderItem.path
      
      Set objFileSystem = CreateObject("Scripting.fileSystemObject")
      
      For i=0 to UBound(arrFonts)
      
         strSourceFile = fontpath & "\" & arrFonts(i)
         strDestinationFile = sDestinationPath & "\" & arrFonts(i)
      
         If NOT objFileSystem.FileExists(strDestinationFile) _
                Then objFolder.CopyHere strSourceFile
          
      Next
      
      wscript.quit
      \Rems


      Similar Threads
      - Installation of font on all computers
      .
      Last edited by Rems; 26th September 2008, 19:40. Reason: Added "Similar Threads"

      This posting is provided "AS IS" with no warranties, and confers no rights.

      __________________

      ** Remember to give credit where credit's due **
      and leave Reputation Points for meaningful posts

      Comment


      • #4
        Re: Script to add fonts to XP

        Thanks guys or should than be Rems and Guys.

        I read the Scripting Guy link that Guy provided but I didn't understand any of it. (My Russian is better than my VB and I only know 3 Russian words)

        I shall try the startup script and see if that will fix the problem. Thanks again.
        1 1 was a racehorse.
        2 2 was 1 2.
        1 1 1 1 race 1 day,
        2 2 1 1 2

        Comment


        • #5
          Re: Script to add fonts to XP


          To the script of the Scripting Guys I had to add the 'IF NOT fileEXISTS' statement, otherwise the logon script will hang when a font-file already exists in the windows\fonts folder (that will be the next time the computer boots again).


          Next change: To avoid having to write the same copyhere-commands for each of the font-files every time again in the script I could have created a subroutine for it, but instead I preferred here to create an Array with all the font-file names in it. The For-Next statement walks through the array and every font-file name passes the 'copyhere method'.


          It will be more difficault however if you would also like to upgrade fonts that were already installed on the computer.
          In that case the script should not only determine if a font-file by that name already exists in the windows\fonts folder;
          º If not exists,
          - copy the new font file to the fonts folder
          º If exists it must compare the lastmodification time,
          - if the existing file is older - then uninstall the older version first - then copy the new font file.
          - if not older, skip go to next.



          Tip, Posted In: Daily Feature , Fonts , Windows . By Anoop Engineer
          A guy called Tsukasa have cooked up a small command line utility which can add and remove fonts to your font cache, without having administrator privileges. However, the command-line(s) need to run over and over, each time the user logs-on again. With this tool you are able to give users a way to controll the use of fonts themselves.
          http://www.dailygyan.com/2008/05/how...s-without.html
          I have no further reference about this tool and I have never tested it, If you are thinking about giving it a try it will be for your own responsibility then.



          \Rems
          ( Спасибо, \Бэры )
          Last edited by Rems; 25th May 2008, 17:40.

          This posting is provided "AS IS" with no warranties, and confers no rights.

          __________________

          ** Remember to give credit where credit's due **
          and leave Reputation Points for meaningful posts

          Comment


          • #6
            Re: Script to add fonts to XP

            Originally posted by Rems View Post
            \Бэры
            Ahhhh !!!!
            Guy Teverovsky
            "Smith & Wesson - the original point and click interface"

            Comment


            • #7
              Re: Script to add fonts to XP

              Originally posted by guyt View Post
              Ahhhh !!!!
              My VB is better than my Russian because I only know 3 Russian words.
              I Stole, borrowed and modified the Russian words. :LOL:

              btw 'Babel Fish' it doing a magical thing with my username.
              Translate Rems (use the same upper and lower cases) from English to Russian
              then back from Russian to English. Ahhhh !!!!

              This posting is provided "AS IS" with no warranties, and confers no rights.

              __________________

              ** Remember to give credit where credit's due **
              and leave Reputation Points for meaningful posts

              Comment


              • #8
                Re: Script to add fonts to XP

                Russian is my mother tongue, yet it took me a while to figure out what that word meant.

                Turns out this is plural for REM, which stands for "Röntgen equivalent man" http://en.wikipedia.org/wiki/R%C3%B6...equivalent_man
                So should we call you X-Man from now on ?

                There is also some archaic word in Ukrainian that is written as "Бэры", which is also plural for something.
                Guy Teverovsky
                "Smith & Wesson - the original point and click interface"

                Comment

                Working...
                X