.MapNetworkDrive - VBScript


MapNetworkDrive establishes a connection to a shared network drive and maps it to a local drive. This allows users to access remote files and folders with the convenience of a local drive. It is commonly used in business environments, system administration, and personal computing.


.MapNetworkDrive DriveLetter, UNCPath, Reconnect, Credential

| Parameter | Description | Required |
| DriveLetter | The letter assigned to the mapped network drive | Yes |
| UNCPath | The Universal Naming Convention (UNC) path of the shared network drive | Yes |
| Reconnect | Boolean value indicating whether to reconnect to the drive if it is disconnected | No |
| Credential | Credential object specifying the username and password for accessing the network share | No |




Simple Example

.MapNetworkDrive "M:", "\\\\Server1\\SharedFolder"

Maps the shared folder “SharedFolder” on server “Server1” to drive “M:” and establishes a connection.

Example with Reconnect

.MapNetworkDrive "N:", "\\\\Server2\\PublicDocs", True

Maps the shared folder “PublicDocs” on server “Server2” to drive “N:” and enables automatic reconnection in case of disconnection.

Example with Credential

Set Credential = CreateObject("WScript.Network.Credential")
With Credential
    .UserName = "Domain\\Username"
    .Password = "Password"
    .Domain = "Domain"
End With

.MapNetworkDrive "O:", "\\\\Server3\\SalesData", False, Credential

Maps the shared folder “SalesData” on server “Server3” to drive “O:” using the specified credentials.

Common Issues

  • Incorrect UNC path: Ensure the UNC path is accurate, including the server name and shared folder name.
  • Insufficient permissions: Verify that the user has sufficient permissions to access the shared network drive.
  • Firewall blocking: Check if the firewall is blocking the connection to the network share.


.MapNetworkDrive can be integrated into complex scripts for automating tasks such as:

  • Accessing network files from multiple machines
  • Backing up data to a remote location
  • Creating a central repository for shared documents

More information on MapNetworkDrive