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.


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: \\\d taschenbier /user:\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: \\\d taschenbier /user:\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

Leave a Reply

Your email address will not be published.