_techie_ Posted May 24, 2011 Posted May 24, 2011 RIGHTT!!!! I have spent about 2.5 hours this afternoon working on trying to install fonts automatically in Windows 7 from a script! So far, I have come up with a basic script that installs the script fine at startup, but it can't seem to check in anyway, whether the font already exists.... Can anyone give me some help with my script - its a vbscript, as below: [b][i]' Fonts.installer ' ---------------------------------------------------------- Option Explicit Dim objShell, objFolder Const FONTS = &H14& Set objShell = CreateObject("Shell.Application") Set objFolder = objShell.Namespace(FONTS) objFolder.CopyHere "\\%server%\%sharename%\!Y2KBUG.ttf" Set objShell = CreateObject("Shell.Application") Set objFolder = objShell.Namespace(FONTS) objFolder.CopyHere "\\%server%\%sharename%\$FIVEDOU.ttf" Wscript.Quit[/i][/b] I don't know if it is something special to do with the Windows/Fonts directory in Windows 7, but nothing I do, can seem to check the exisitance of a font already in the directory.... Can anyone help! Cheers _techie_
Steve21 Posted May 24, 2011 Posted May 24, 2011 So far, I have come up with a basic script that installs the script fine at startup, but it can't seem to check in anyway, whether the font already exists.... Can anyone give me some help with my script - its a vbscript, as below: Can you show the code you're trying to use to check if they exist? Easier to see if something's wrong if you post it Steve
_techie_ Posted May 24, 2011 Author Posted May 24, 2011 I have posted the code in my previous post. ^^^ Cheers _techie_
Steve21 Posted May 24, 2011 Posted May 24, 2011 I have posted the code in my previous post. ^^^ Cheers _techie_ Well you haven't checked if files exist at all... Nor do you have any variables etc etc So did you try to check it, or prefer just full version posted? Don't mind either way Try this: On error resume next dim fontlist(3),root,path,check,filelist fontlist(0)="font1.TTF" fontlist(1)="font2.TTF" fontlist(2)="font3.TTF" fontlist(3)="font4.TTF" Set fso = CreateObject("Scripting.FileSystemObject") filepath = fso.GetParentFolderName(wscript.ScriptFullName) set wshShell = Wscript.CreateObject("Wscript.shell") fontpath = wshShell.ExpandEnvironmentStrings("%windir%") Const FONTS = &H14& Set objShell = CreateObject("Shell.Application") Set objFolder = objShell.Namespace(FONTS) for each font in fontlist copyto=filepath+"\"+font check_file=fontpath+"\fonts\"+font if fso.FileExists(check_file) then root=0 else objFolder.CopyHere copyto end if next Steve
Arthur Posted May 24, 2011 Posted May 24, 2011 Would this script be of any use? http://www.edugeek.net/forums/how-do-you-do/70896-deploying-font-all-pcs.html#post657005
ZeroHour Posted May 24, 2011 Posted May 24, 2011 Here is a script that works. Const FONTS = &H14& Dim wsh Set wsh = WScript.CreateObject("Wscript.Shell") function LogtoEvent (MSG,success) select case success case 1 wsh.LogEvent EVENT_SUCCESS, MSG ' 1 is a success case 0 wsh.LogEvent EVENT_FAILURE, MSG ' 0 is a error case 2 wsh.LogEvent EVENT_WARNING, MSG ' 2 is a warning case 3 wsh.LogEvent EVENT_INFORMATION, MSG ' do not use end select end function LogtoEvent "INSTALL FONTS: Started Installing Fonts",1 strSource = "\\{UNC PATH TO DIR WITH FONTS}" arrFiles = Array("{FONT NAME.ttf", "{ANOTHER FONT NAME.ttf}") Set objShell = CreateObject("Shell.Application") Set objFolder = objShell.Namespace(FONTS) For Each strFile in arrFiles Set objFolderItem = objFolder.ParseName(strFile) If objFolderItem is nothing Then LogtoEvent "INSTALL FONTS: Installing " & strFile,1 objFolder.CopyHere strSource & "\" & strFile, &H4& End If Next LogtoEvent "INSTALL FONTS: Done",1 This leaves entries in the event log too ftw
_techie_ Posted May 24, 2011 Author Posted May 24, 2011 in answer to steve21 well..I ran a BAT file with the following: @echo OFF IF EXIST "C:\WINDOWS\Fonts\!Y2KBUG.ttf" GOTO END wscript.exe "C:\font_installer.vbs" :End ECHO Font installed correctly However...this just went straight to End immediately! If I just run the wscript.exe part it installs the fonts fine, but just repeats the issue everytime the bat file runs :-(
sted Posted May 24, 2011 Posted May 24, 2011 i just used winstall and made an msi that has worked for me in he past if i needed to get fonts to a win7 box
enjay Posted September 23, 2011 Posted September 23, 2011 Here is a script that works. So I should save that as a .vbs and stick it in NetLogon, yes?
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now