Windows: Mount and unmount network drives with batch file

Mount and unmount network drives in Windows at the command prompt, here’s how.

Network drives can be connected and disconnected not only via the Explorer, but also via the command prompt. If you are often on different networks, you can quickly connect to network shares for the respective network.

Video

Mount share as drive

A connection can be made with the following command:

net use Z: \\computername\share password /user:domain\username

An example:

net use Z: \\192.168.178.96\d taschenbier /user:192.168.178.96\userle

The share is mounted as drive z:.

In this case, the connection is included until the next restart. To mount a share permanently, we add the parameter “/persistent:yes”.

net use Z: \\192.168.178.96\d taschenbier /user:192.168.178.96\userle /persistent:yes

Disconnect network drive

Network drives can of course be disconnected again. Individual drives can be separated in this way:

net use z: /delete

All network drives can also be disconnected in one go:

net use * /delete /y

One comment

  1. I was trying to delete shared drive but can’t delete also unmount eject to this from my pc ,
    any idea how can i delete this RDP shared resouces from my server
    C:\Windows\System32>net use z: /delete
    z: was deleted successfully.

    C:\Windows\System32>net use
    New connections will not be remembered.

    Status Local Remote Network

    ——————————————————————————-
    \\TSCLIENT\C Microsoft Terminal Services
    The command completed successfully.

    C:\Windows\System32>net use * /delete /y
    You have these remote connections:

    \\TSCLIENT\C
    Continuing will cancel the connections.

    The command completed successfully.

    C:\Windows\System32>net use
    New connections will not be remembered.

    Status Local Remote Network

    ——————————————————————————-
    \\TSCLIENT\C Microsoft Terminal Services
    The command completed successfully.

    C:\Windows\System32>

Leave a Reply

Your email address will not be published. Required fields are marked *