Force a network drive to disconnect via command-line

This is now getting rather annoying – sometimes when I try to remove a network drive using the:
 

net use [drive] /delete

 
command, it gives me the error saying:

The device is being accessed by an active process.

More help is available by typing NET HELPMSG 2404.

 
 
Does anyone know how I can force that drive to disconnect via command-line? 
(Yes, I’ve already CD-ed out of the drive before you say anything….
Also, I know you can do this via explorer – but I just prefer using the CLI…)
 
About these ads

13 Responses to “Force a network drive to disconnect via command-line”

  1. Emmanuel Says:

    Add a /yes switch to your commandnet use [drive] /delete /yes

  2. bob Says:

    To anyone finding this from Google – the above tip doesn’t work – adding /yes doesn’t force the drive to disconnect.

  3. Alex Says:

    “net use H: /delete /yes” is the command I’ve been trying. Doesn’t work

  4. woutie Says:

    /yes indicates that you do not have to press YES or NO when the system asks you if you want to disconnect when there are open files.
    It’s usefull, especially for scripts.

  5. skyline Says:

    Net Use /d H: /Y
    Will discconect the drive if there are files still open and suppress the prompting of YES/NO

    BUT
    The problem that is being experienced is an active process not open files.
    You should track down the process accessing the device and kill it.

  6. A Says:

    Seems a Windows networking problem, there is no process accessing the drive, but Windows thinks that there is. So just restart it,……

  7. David Says:

    This is incredibly frustrating. I have mapped to a NAS because I want to back up files to it but after the backup I want to completely disconnect to isolate the machines. I have not yet found a way to disconnect. This seems like a huge security issue to me.

  8. Kervin Says:

    I´ve has finally found a solution to this, and I would like to share it, so here we go…
    If you have a problem like this:
    - Trying to disconnect a mapped drive via UI (right click -> disconnect) or command line (net use x /delete) without any luck
    - You´ve also checked start->control panel->administrative tools->computer management->shared folders->open files and nothing is in use
    - and still getting from windows this message “The device is being accessed by an active process”
    - so you´re at the point when rebooting is your only option
    - there are still hope, use the force and also this…
    (Windows UI)
    Ctrl+Alt+Delete -> Task Manager -> Processes -> find explorer.exe -> click on “End Process” button -> now go to the command prompt and type “net use x /delete /yes” -> this time windows will behave as expected -> then as a Jedi, return to the Windows Task Manager windows and select -> File -> New Task (Run…) -> type “explorer.exe” and the force balance will be reestablish again, so your users will cheer you up to save the galaxy one more time :)

    Kervin

    • Kat Says:

      Great advice! My users are much happier now that they don’t have to reboot to fix this. I made it into a batch file so it’s easier for them fix themselves. This kills explorer, deletes all network shares, and then starts explorer again. It doesn’t seem to close by itself in my test run, but it works great:

      @echo off
      taskkill /f /im explorer.exe
      net use * /delete /yes
      explorer.exe

  9. Jared Says:

    After doing some research I found an easier method that worked for me. Just try
    C: net use * /d /y

  10. Thiago Says:

    Hi guys,
    i’ve tried every method, in debug mode is working, but when i run a dtexec, the window is open with asked confirmation for delete.
    Please, help me!
    i’m try:
    - net use n: /delete /yes
    - net use n: /delete /y
    - net use n: /d /yes
    - net use n: /d /y


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: