20

Windows 7

When moving from office A to office B, I have a script that deletes (net use x: /d) the drive mappings from office A, but the drive links remain prominently visible in Windows Explorer / My Computer. They are prominently displayed under Network Location.

The disconnected links have a big red X through them and right-clicking on them and choosing Disconnect results in an error message saying that that drive mapping no longer exists.

How can I force Windows to remove them once they've been disconnected?

Without rebooting? (Scriptable)

28

There is an easy way to do this: restart Windows Explorer (without shutting down). You could do this with a batch file, like the following:

@echo off
net use * /delete /noconfirm
taskkill /f /IM explorer.exe
explorer.exe
net use x: \\myServer\mySHaredFolder
  • Was /noconfirm added in Windows 7? Vista does not recognize it (and consequently the delete command fails) – Michael Apr 24 '13 at 3:54
  • 2
    Note to Googlers: "/noconfirm" error still present in Windows 8.1 – MickyD Jun 9 '15 at 11:22
  • 1
    as per @MickyD /noconfirm is not an option in Windows 10 however net use K: /delete works perfectly (did not try *) – rob Jun 15 '17 at 8:19
10

(Windows 8.1 Tested) restart Windows Explorer by killing and restarting the process in the Task Manager. Right-click Windows Explorer -> Restart. Done.

  • 4
    The only thing that worked (Win 10). – StepTNT Jan 11 '16 at 19:24
  • You'd think instead of constantly adding pointless stuff and changing things that didn't need changing, Microsoft would have gotten around to adding a "Disconnect and remove drive mapping" menu entry. But no, it's far more important to add a completely useless mobile tile-based GUI ... – antred Jun 7 '17 at 12:36
  • solution works, without restarting the server cool , Thanks : ) – Irfan Apr 3 '18 at 13:59
6

First, you need have a "Shared Folder" on your hard drive. If you haven't got one already, create a new folder on your hard drive called "Shared", then right-click it and select properties. Click the Sharing tab and tick the "Share this folder" box.

Next, click "My Computer" and in the Tools Menu, click "Map Network Drive".

Notice the little down-arrow next to the drive letter shown. Click the arrow to get a list of letters. Select the one you want to delete, then browse for your Shared folder and select it.

By this means, you will assign the drive letter to a real folder. Make sure the "reconnect at login" box is un-ticked.

Click the Finish button to get a warning. Answer "Yes" and the Shared folder will open. Close it.

Next, right-click the drive in My Computer and select disconnect. Ah, I hear you say, but it is still there! Reboot and it should now be gone.

  • 1
    Excellent answer, David, thank you. I need to force removal without rebooting, though. Possible? – cssyphus Jun 11 '12 at 18:45
  • I think you can you log out and log back in without rebooting the entire system. Other than that, I'm out of ideas. Perhaps someone can chime in on this. – superuser Jun 11 '12 at 18:54
  • 1
    This doesn't seem to work if you get the message about having to have a user name and password on the computer for sharing to work. – Michael Apr 24 '13 at 3:58
1

I had a problem like this recently, where I had 8 drive letters that didn't show up anywhere, but I couldn't map any new drives of any kind to these letters. What it turned out to be was that they were mapped to "CD-ROM" drives. I have no idea how this happened, but I had eight CD-ROM drives that didn't actually exist. And they were using drive letters that until this problem I had "persistently" mapped to network devices. :Net use [drive]: /delete" had no effect at all.

The only way I got them to release was to go into the Partition Manager control panel and individually disconnect the drive letters from the CD-ROM drives. So far the blocking drives themselves are still in the list in Disk Manager, but hopefully they will go away with another reboot.

1

You can restart Windows Explorer using Task Manager. Kill the explorer process, then go to menu FileNew Task (run) and type explorer. Disconnected drives should be gone! (tested on Windows 7).

1

For those who have SQL Server Management Studio on your PC, just run this query:

Exec master.dbo.xp_cmdshell 'net use x: /delete'

** Change the 'x' according to the drive name...

  • 2
    How is this an improvement over performing net use x: /delete /noconfirm at the command prompt? – Jason Aller May 22 '15 at 5:04
1

I had the same issue; one quick version that works (Windows 7 - 10 at least):

  • Open command prompt as admin
  • Type:

    net use /persistent:no
    
  • Hit Enter
  • Then open Task Manager (on details for Windows 8+) right click explorer and kill it, then go to file, run, and type explorer (hit Enter) to restart it.

Your dead network drives should vanish under My/This computer.

Not the answer you're looking for? Browse other questions tagged or ask your own question.