复制字体时,CopyHere 无法按预期工作 [英] CopyHere not working as expected when copying fonts

查看:26
本文介绍了复制字体时,CopyHere 无法按预期工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我制作了一个脚本,它应该将一堆字体复制到 Windows 字体文件夹中.当我运行它时,我收到了我想要复制的文件名的输出,但没有复制.当我删除 For 循环并指定文件名时,它会起作用.任何帮助表示赞赏.

I made a script, which is supposed to copy a bunch of fonts to the Windows font folder. When I run it, I receive the output of the file names I would like copied, but nothing copies. It works when I remove the For loop, and specify file names. Any help appreciated.

Const FONTS = &H14&
sFolder = "c:\FontInstalls\"
Set objShell = CreateObject("Shell.Application") 
Set objFolder = objShell.Namespace(FONTS) 
Set objFSO = CreateObject("Scripting.FileSystemObject")

For Each oFile In objFSO.GetFolder(sFolder).Files
  If UCase(objFSO.GetExtensionName(oFile.Name)) = "TTF" Then
    objFolder.CopyHere(oFile)
    wscript.echo(oFile)
  End if
Next

推荐答案

字体需要安装而不是复制.复制外壳的对象而不是底层文件.shell 安装复制到 fonts 文件夹中的字体.

Fonts need to be installed not copied. Copy the shell's objects rather than underlying files. The shell installs fonts copied into the fonts folder.

这是您需要将文件添加到 zip 中的对象.

Here's the objects you need adding files to a zip.

Set objShell = CreateObject("Shell.Application")
Set Ag=Wscript.Arguments
set WshShell = WScript.CreateObject("WScript.Shell")

Set SrcFldr=objShell.NameSpace(Ag(1))
Set DestFldr=objShell.NameSpace(Ag(0))
Set FldrItems=SrcFldr.Items
DestFldr.CopyHere FldrItems, &H214
Msgbox "Finished"

这篇关于复制字体时,CopyHere 无法按预期工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆