I am using code from another co-worker to map drives to other machines, then copy files over to those mapped drives. I keep getting the
The local device name is already in use.
error for this line
objNetwork.MapNetworkDrive
"N:", "\\Prodweb10\DMProEducatio
n", False, "IUSR_NEW-WEB", "uploaduser"
HERES MY CODE
' Create objects
set objFileSystem=CreateObject
("Scriptin
g.FileSyst
emObject")
Set objNetwork = Server.CreateObject("WScri
pt.Network
")
' Unmap any previous mapped drives
Set colDrives = objNetwork.EnumNetworkDriv
es
For i = 0 to colDrives.Count-1 Step 2
If Instr(colDrives.Item (i + 1), "\\Prodweb10") > 0 Then
objNetwork.RemoveNetworkDr
ive colDrives.Item (i)
End If
If Instr(colDrives.Item (i + 1), "\\Prodweb12") > 0 Then
objNetwork.RemoveNetworkDr
ive colDrives.Item (i)
End If
Next
Set colDrives = Nothing
' Map drive to a shared folder on the production servers
objNetwork.MapNetworkDrive
"N:", "\\Prodweb10\DMProEducatio
n", False, "IUSR_NEW-WEB", "uploaduser"
objNetwork.MapNetworkDrive
"L:", "\\Prodweb12\DMProEducatio
n", False, "IUSR_NEW-WEB", "uploaduser"
If strImageName <> "" Then
' Copy folder to production servers
objFileSystem.CopyFile destination & "\" & strImageName, "N:\images\", True
objFileSystem.CopyFile destination & "\" & strImageName, "L:\images\", True
End If
' Unmap any previous mapped drives
Set colDrives = objNetwork.EnumNetworkDriv
es
For i = 0 to colDrives.Count-1 Step 2
If Instr(colDrives.Item (i + 1), "\\Prodweb10") > 0 Then
objNetwork.RemoveNetworkDr
ive colDrives.Item (i)
End If
If Instr(colDrives.Item (i + 1), "\\Prodweb12") > 0 Then
objNetwork.RemoveNetworkDr
ive colDrives.Item (i)
End If
Next
' Clean up
Set colDrives = Nothing
set objFileSystem = Nothing
Set objNetwork = Nothing
I am not a strong vb guy, more of an asp guy.
Thanks
Start Free Trial