在网络上找到的以下脚本可以很好地映射Windows 7中的网络驱动器。
我想要做的是在同一个脚本中添加另一个映射驱动器,但我不熟悉VBS脚本,因此寻求您的专家建议!
非常感谢!
丹
' MNDArguments.vbs
' VBScript to map a network drive with all 5 arguments.
' Author Guy Thomas http://computerperformance.co.uk/
' Version 1.3 - April 24th 2010
' ---------------------------------------------------------'
Option Explicit
Dim objNetwork
Dim strDriveLetter, strRemotePath, strUser, strPassword, strProfile
' Values of variables set
strDriveLetter = "H:"
strRemotePath = "\\alan\home"
strUser = "guytom"
strPassword = "P@ssw0rd1"
strProfile = "false"
' This section creates a network object. (objNetwork)
' Then apply MapNetworkDrive method. Result H: drive
' Note, this script features 5 arguments on lines 21/22.
Set objNetwork = WScript.CreateObject("WScript.Network")
objNetwork.MapNetworkDrive strDriveLetter, strRemotePath, _
strProfile, strUser, strPassword
WScript.Quit
' End of Example script .
答案 0 :(得分:2)
映射第一个驱动器后,将变量更改为第二个位置,在strDriveLetter
中使用不同的驱动器号,然后再次调用objNetwork.MapNetworkDrive
。
strDriveLetter = "H:"
strRemotePath = "\\alan\home"
strUser = "guytom"
strPassword = "P@ssw0rd1"
strProfile = "false"
' This section creates a network object. (objNetwork)
' Then apply MapNetworkDrive method. Result H: drive
' Note, this script features 5 arguments on lines 21/22.
Set objNetwork = WScript.CreateObject("WScript.Network")
objNetwork.MapNetworkDrive strDriveLetter, strRemotePath, _
strProfile, strUser, strPassword
strDriveLetter = "I:"
strRemotePath = "\\Some\Network\Path"
objNetwork.MapNetworkDrive strDriveLetter, strRemotePath, _
strProfile, strUser, strPassword
(即使您不熟悉VBScript,也应该通过阅读您发布的代码来解决这个问题。)
答案 1 :(得分:2)
Option Explicit
Dim objNetwork, i
Dim strDriveLetter, strRemotePath, strUser, strPassword, strProfile
Dim arrDrives(1,4)
arrDrives(0, 0) = "H:"
arrDrives(0, 1) = "\\alan\home"
arrDrives(0, 2) = "guytom"
arrDrives(0, 3) = "P@ssw0rd1"
arrDrives(0, 4) = "false"
arrDrives(1, 0) = "I:"
arrDrives(1, 1) = "\\tom\home"
arrDrives(1, 2) = "tomguy"
arrDrives(1, 3) = "P@ssw0rd1"
arrDrives(1, 4) = "false"
For i = 0 To UBound(arrDrives)
Set objNetwork = WScript.CreateObject("WScript.Network")
objNetwork.MapNetworkDrive arrDrives(i, 0), arrDrives(i, 1), _
arrDrives(i, 4), arrDrives(i, 2), arrDrives(i, 3)
Next
WScript.Quit
将arrDrive(0,0)复制/粘贴到(0,4)以添加另一个驱动器。不要忘记更改Dim arrDrives(驱动器数量减去1,4)。