English 中文(简体)
B. 阿雷拉的制图网络运动
原标题:mapping network drive with Array

问题正在讨论(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
问题回答

不管怎样,这似乎是一个时间的复杂过程,用于绘制动脉图,这样一米不会打破我的头脑,而只是手脚。 反之“待绘制——和”;“+新的MappingArray(j)必须是坑。 环斑文中没有分类,而是“灯”;

因此,在任何地方,你们都使用+,它应当变成和安放。

您可以通过以下方式缩短发言时间:

oldMappingArray = ("u_amr_project", "U_AMS_Deployment", ...)

如果需要全方位使用,

"\DDCSHRNASP02" & oldMappingArray(j)




相关问题
What approach should I use to test a VBScript?

I ve been asked to help out with a project which has made extensive use of VBScript to process a whole bunch of text files and generate certain outputs - sanitized files, SQL entries etc.. The script ...

Unable to call c# code from vbscript - ActiveX error

I am trying to call a method I have written in C# from VBScript. I have followed just about all of the instructions I can find on the web and am still having problems. Specifically I am getting Error:...

How to set delay in vbscript

How to set delay in vbscript? WScript.Sleep(100) does not work on Windows XP, Vista.

Using Classes in a Dictionary in Classic ASP

I usually do C# but have inherited a classic ASP project. I have defined a class: Class clsPayment Public Name End Class Set objPayment = New clsPayment objPayment.Name = "...

How to check which Operating System?

How can I check OS version in a batch file or through a vbs in an Windows 2k/2k3 environment ? You know ... Something like ... : "If winver Win2k then ... or if winver Win2k3 then ....

Problem casting field when querying spreadsheet

I am trying to query an .xls spreadsheet with VBScript, but I have run into an issue when trying to cast a field. I connect to the spreadsheet like this. Set objConnection = CreateObject("ADODB....

热门标签