映射网络驱动器VBS脚本
On error resume next
strRemotePath = "\\UNC路径"
strNewName = "要显示的名称"
Set objNetwork = CreateObject("Wscript.Network")
Set colDrives = objNetwork.EnumNetworkDrives
For i = 0 to colDrives.Count-1 Step 2
Set objShell = CreateObject("Shell.Application")
strDriveLetter = colDrives.Item(i)
strName = objShell.NameSpace(strDriveLetter).Self.Name
strName = Left(strName,Len(strName)-5)
If strName = strNewName Then WScript.Quit
strRemotePath = "\\UNC路径"
strNewName = "要显示的名称"
Set objNetwork = CreateObject("Wscript.Network")
Set colDrives = objNetwork.EnumNetworkDrives
For i = 0 to colDrives.Count-1 Step 2
Set objShell = CreateObject("Shell.Application")
strDriveLetter = colDrives.Item(i)
strName = objShell.NameSpace(strDriveLetter).Self.Name
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("WScript.Network")
objNetwork.MapNetworkDrive strDriveLetter, strRemotePath vbs脚本怎么停止
' Section which actually (re)names the Mapped Drive
Set objShell = CreateObject("Shell.Application")
objShell.NameSpace(strDriveLetter).Self.Name = strNewName
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论