• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1488
  • Last Modified:

Unable to disconnect network drive windows

I have mapped a network drive using the WScript object through an ASP page. See below:

Set WshNetwork= CreateObject("WScript.Network")
Set oDrives = WshNetwork.EnumNetworkDrives

WshNetwork.MapNetworkDrive driveletter,"remoteserver", False, "username", "password"

' do some work
      
WshNetwork.RemoveNetworkDrive (driveletter)
Set WshNetwork= Nothing

This all seems to work fine except sometimes the drive doesn't get removed and when i log into the server to try and disconnect the drive, it tells me the network connection cannot be found. The network drive is displayed with a red 'X' over it. If I try to remap it, it does not appear in the list of drives. If i use the net use delete command it doesn't work either. The only solution I have found to this problem is rebooting the server and there's only a certain number of times a day i like to do that. Any suggestions would be great as I've been trying to solve this problem for a while now.
0
Splinst
Asked:
Splinst
1 Solution
 
Fatal_ExceptionCommented:
Check the following registry keys for the Dword values below.  I doubt whether this is the problem though, since it is primarily for only removing the context menu option, but you may want to ck anyway...

User Key: [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\
Explorer]
System Key: [HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\
Explorer]
Value Name: NoNetConnectDisconnect
Data Type: REG_DWORD (DWORD Value)
Value Data: (0 = disabled, 1 = enabled)
0
 
SplinstAuthor Commented:
that didn't seem to show up anything but thanks anyway. Any other ideas?
0
 
stardust126Commented:
Next time it happens to you, search the registry for the mapped drive and delete the realted key.
See if it fixes your problem without booting the server.
0
 
catknowsCommented:
Commonly when one disconnects a network drive, one should flush out all the remaining data the the cashe memory.  When open a file and does some change to it and close, windows might not actually update it until when it's free.  Calling disconnecting routine without calling cleaning up routines, might result in disconnecting the network incomplete.  I don't know .NET programming, but that is the general rules.

Hope that help.
0
 
BbluesCommented:
I had same problem.
Here workaround:
in this example x: drive
-cmd delete net network drive: net use x: /d
- regedit remove following folder 'x' under reg-key [HKCU]\Network
Reboot system.
hope this helps

0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now