Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cannot remap network drive

Status
Not open for further replies.

johnisotank

Technical User
Aug 8, 2008
258
GB
Hi, could someone help with this pls...

I have a mapped network drive (M:) that points to our server '\\ServerA\Data'.

I trying to use this vb script to change the network drive to '\\ServerB\Data'.

Code:
Set ObjNetwork = WScript.CreateObject("WScript.Network") 
objNetwork.MapNetworkDrive "M:" , "\\ServerB\data"

But I get the following error:

'The local device name has a remembered connection to another network resource'

Any ideas?

Thanks
John
 
Code:
Set ObjNetwork = WScript.CreateObject("WScript.Network")
objNetwork.RemoveNetworkDrive "M:", True
objNetwork.MapNetworkDrive "M:", "\\ServerB\data"

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Hi PHV many thanks for the reply.

Unfortunately this doesn't work.

When I run the script it 'disconnects' the current M drive (but still appears in network drive list) but then gives me the error

'The local device name has a remembered connection to another network resource'

If I run the code again (without doing anything else) it says

'This network connection does not exist.'

Is there anything else I could try?

Thanks
John
 
Typed, untested:
Code:
Set ObjNetwork = WScript.CreateObject("WScript.Network")
On Error Resume Next
objNetwork.RemoveNetworkDrive "M:", True, True
On Error Goto 0
objNetwork.MapNetworkDrive "M:", "\\ServerB\data"

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Superb,

thanks a lot mate, really appreciate that.

John
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top