0

以下脚本可在网络上找到,非常适合在 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 .
4

2 回答 2

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。)

于 2013-04-10T22:48:24.987 回答
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)。

于 2013-04-10T23:03:06.710 回答