vbscript - Getting VBS script to use network share location
问题描述
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
Source cannot be \\172.31.0.5\Fonts, I tried this and it won't load the fonts. However, when the drive number (X:\Fonts) is used, it works. How can I change this so I can just install them from the network location without using the drive letter? It is for a deployment server. Thank you.
解决方案
您省略了共享名称。X:\Fonts 表示 \172.31.0.5\sharename\Fonts。您需要找出共享名称并将其粘贴。
推荐阅读
- ios - 检查外部 ble 设备的最佳方法仍然快速连接到应用程序
- flutter - 如何使用 Flutter 将二维码下载到用户设备?
- php - 在设计方面我应该如何在左侧和右侧显示聊天消息
- c++ - 在两个类中共享相同的函数调用,并在不需要时避免空实例化
- unity3d - 在运行时统一切换 3d 模型的最佳方法
- html - 轮播内容更改高度/内容时页面跳转
- sql - 在 Oracle 中动态时间戳 2 天后每天计算计数
- android - 如何使用 Retrofit 和 Gson 解析嵌套列表?
- rails-activestorage - 在生产中访问本地存储的活动存储文件
- excel - 导出带格式和不带公式的工作簿副本