映射网络驱动器VBS脚本
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
映射网络驱动器VBS脚本
On error resume next
strRemotePath = "\\UNC路径"
strNewName = "要显示的名称"
Set objNetwork = CreateObject("work")
Set colDrives = objNetwork.EnumNetworkDrives
For i = 0 to colDrives.Count-1 Step 2
Set objShell = CreateObject("Shell.Application")
strDriveLetter = colDrives.Item(i)
strName = Space(strDriveLetter) strName = Left(strName,Len(strName)-5)
If strName = strNewName Then WScript.Quit
strDriveLetter = Chr(Asc(Left(colDrives.Item(i),1))-1) & ":"
Next
If strDriveLetter= "" Then strDriveLetter="Z:"
' Section to map the network drive
Set objNetwork = CreateObject("work") objNetwork.MapNetworkDrive strDriveLetter, strRemotePath
' Section which actually (re)names the Mapped Drive
Set objShell = CreateObject("Shell.Application")
Space(strDriveLetter) = strNewName