robie2011
4/30/2014 - 2:05 PM

Installing new Fonts on Windows with VBS

Installing new Fonts on Windows with VBS


' http://blogs.technet.com/b/rspitz/archive/2010/09/25/how-to-install-a-font-from-the-command-line-on-windows-7.aspx

strPathFonts = "\\share\fonts"

set Shell = WScript.CreateObject("WScript.Shell")
strWindir = Shell.ExpandEnvironmentStrings("%windir%")


set fso = CreateObject("Scripting.FileSystemObject")
set f = fso.GetFolder(strPathFonts)


Set fc = f.Files
For Each fl in fc
	 'wscript.echo strWindir  + "\fonts\" +fl.name
	 
	if (fso.FileExists("C:\Windows\Fonts\" +fl.name)) then
		 'wscript.echo "existiert bereits"
	else
		'wscript.echo "install ..."
		installFont strPathFonts, fl.name
	end if
Next


function installFont(path, file)
	set objShell = CreateObject("Shell.Application")
	set objFolder = objShell.Namespace(path)
	set objFolderItem = objFolder.ParseName(file)
	objFolderItem.InvokeVerb("Install")	
end function