Option Explicit
Dim objShell, objFSO, wshShell
Dim strFontSourcePath, objFolder, objFont, objNameSpace, objFile
Set objShell = CreateObject("Shell.Application")
Set wshShell = CreateObject("WScript.Shell")
Set objFSO = createobject("Scripting.Filesystemobject")
Wscript.Echo "--------------------------------------"
Wscript.Echo " Install Fonts "
Wscript.Echo "--------------------------------------"
Wscript.Echo " "
strFontSourcePath = "\\172.31.0.5\Fonts"
If objFSO.FolderExists(strFontSourcePath) Then
Set objNameSpace = objShell.Namespace(strFontSourcePath)
Set objFolder = objFSO.getFolder(strFontSourcePath)
For Each objFile In objFolder.files
If LCase(right(objFile,4)) = ".ttf" OR LCase(right(objFile,4)) = ".otf" Then
If objFSO.FileExists("C:\Windows\Fonts\" & objFile.Name) Then
Wscript.Echo "Font already installed: " & objFile.Name
Else
Set objFont = objNameSpace.ParseName(objFile.Name)
objFont.InvokeVerb("Install")
Wscript.Echo "Installed Font: " & objFile.Name
Set objFont = Nothing
End If
End If
Next
Else
Wscript.Echo "Font Source Path does not exists"
End If
源不能为\\ 172.31.0.5 \ Fonts,我尝试过此操作,它不会加载字体。但是,使用驱动器号(X:\ Fonts)时,它将起作用。如何更改此设置,以便仅从网络位置安装它们而不使用驱动器号?它用于部署服务器。谢谢。
答案 0 :(得分:0)
您已省略共享名。 X:\ Fonts表示\ 172.31.0.5 \ sharename \ Fonts。您需要找出共享名并将其粘贴。