问题正在讨论(objNetwork)。 地图网络驱动力CStr(栏目驱动器,Item(i)),CStr(NewMappingArray(j)), TRUE,在座标本实际上试图重新连接网络。 它之所以失败,是因为它把它看作是一种扼杀?
i 试图在路边使用“”的同一法典,并驾车,但不能确定从何处去。
CODE DESCRIPTION it takes a list of share names, checks if any of the remote paths are mapped to drives. IF they are then it goes through them. unmaps them, uses the same drive letter and remaps them using the new path reference(with currently logged in credentials..
简称
On Error Resume Next
ARRAY SETUP
DIM oldMappingArray(5)
oldMappingArray(0) = "\DDCSHRNASP02u_amr_project"
oldMappingArray(1) = "\DDCSHRNASP02U_AMS_Deployment"
oldMappingArray(2) = "\DDCSHRNASP02u_corp_share"
oldMappingArray(3) = "\DDCSHRNASP02u_dcwb_control_room"
oldMappingArray(4) = "\DDCSHRNASP02u_dis"
oldMappingArray(5) = "\DDCSHRNASP02u_dis15"
oldMappingArrayLength = UBound(oldMappingArray)
DIM newMappingArray(5)
newMappingArray(0) = "\EUCPRDNAS02u_amr_project"
newMappingArray(1) = "\EUCPRDNAS02U_AMS_Deployment"
newMappingArray(2) = "\EUCPRDNAS02u_corp_share"
newMappingArray(3) = "\EUCPRDNAS02u_dcwb_control_room"
newMappingArray(4) = "\EUCPRDNAS02u_dis"
newMappingArray(5) = "\EUCPRDNAS02u_dis15"
newMappingArrayLength = UBound(newMappingArray)
WMI SETUP
Set objNetwork = CreateObject("Wscript.Network")
Set colDrives = objNetwork.EnumNetworkDrives
colDrivesLength = colDrives.count
wscript.echo colDrivesLength
MAIN LOOP
For i=0 to colDrivesLength-1 Step 2
Gets every other in the array, making i equal to a PATH
wscript.echo i
For j=0 to oldMappingArrayLength
count through all of the old path names
wscript.echo j
wscript.echo "Drive Letter = " + colDrives.Item(i) Drive letter
wscript.echo "Current Path = " + colDrives.Item(i+1) Path of the Drive Above
wscript.echo "Tested Path = " + oldMappingArray(j) Path Currently Testing
if colDrives.Item(i+1) = oldMappingArray(j) then
If the drive path from enumeration is equal to the old drive mapping array...
wscript.echo "Item being added -> " + colDrives.Item(i)
wscript.echo "to be mapped ---> " + newMappingArray(j)
objNetwork.RemoveNetworkDrive colDrives.Item(i), True, True
WScript.sleep 3000 Wait 1.0 seconds
objNetwork.MapNetworkDrive CStr(colDrives.Item(i)), CStr(newMappingArray(j)), TRUE
exit For ends the oldMappingArrayLength loop if a match was found
End If
Next
Next
Set objNetwork = Nothing