On Windows, you can mount an SMB shared folder as a network drive. It is often useful to be able to mount such a drive from a command-line or batch-script.
Mounting a network drive from command-line is done line this:
net use X: \\servername\sharename /user:domain\username "password"
Note that the network drive will only be mounted for the duration of the
script.
If you need the network drive to be mounted permanently, you can add
the /persistent:yes
parameter to the
net use
command
Compatibility
This should work on all modern versions of Windows, including:
- Microsoft Windows 11
- Microsoft Windows 10
- Microsoft Windows 8
- Microsoft Windows 7
- Microsoft Windows Server 2022
- Microsoft Windows Server 2019
- Microsoft Windows Server 2016
- Microsoft Windows Server 2012
- Microsoft Windows Server 2008