Command — Line To Map Network Drive

Stop Clicking: How to Map Network Drives via Command Line We all know the routine: Open "This PC," click the "..." menu, select "Map network drive," choose a letter, paste the path, and hit finish. It works, but it is slow, repetitive, and impossible to automate. If you are setting up a new machine, writing a login script, or just want to feel like a hacker, mapping drives via the Command Prompt ( cmd ) or PowerShell is the way to go. Here is how to do it efficiently. The Classic Method: Using net use The net use command has been a staple of Windows administration for decades. It is robust, simple, and works in the standard Command Prompt. The Basic Syntax To map a drive, open your Command Prompt and type: net use Z: \\ServerName\ShareName

In this example:

Z: is the drive letter you want to assign. \\ServerName\ShareName is the path to the network folder.

Mapping with Credentials Often, you need to connect with a specific username and password. You can add those flags to the end of the command: net use Z: \\ServerName\ShareName /user:Domain\Username Password123 command line to map network drive

/user: Allows you to specify a different user account. Password123: The password for that account (note: this is visible on screen, so be careful).

Making it Persistent (The "Reconnect at Sign-in" Box) By default, command-line mappings are often not persistent (they disappear after a reboot). To make them stick, add the /persistent:yes switch. net use Z: \\ServerName\ShareName /persistent:yes

The "Complete" Command Putting it all together, a fully automated login script command looks like this: net use Z: \\ServerName\ShareName /user:Domain\Username Password123 /persistent:yes Stop Clicking: How to Map Network Drives via

The Modern Method: PowerShell If you prefer PowerShell, you have more object-oriented control over the process. The cmdlet to use is New-PSDrive . The Basic PowerShell Syntax New-PSDrive -Name "Z" -PSProvider FileSystem -Root "\\ServerName\ShareName" -Persist

-Name: The drive letter (no colon needed). -Persist: This is the equivalent of "Reconnect at sign-in." It makes the drive visible in File Explorer. -PSProvider: Usually FileSystem, but good to specify explicitly.

Mapping with Credentials in PowerShell PowerShell handles credentials more securely than CMD. You can store credentials in a variable first: $cred = Get-Credential New-PSDrive -Name "Z" -PSProvider FileSystem -Root "\\ServerName\ShareName" -Persist -Credential $cred Here is how to do it efficiently

Running this will pop up a standard Windows credential dialog box, keeping your password secure.

Common Issues & Troubleshooting 1. "System error 67 has occurred" This usually means the network path is incorrect. Check your spelling and ensure you are using backslashes ( \ ) rather than forward slashes ( / ) in the path. 2. "The local device name is already in use" You are trying to map a drive letter that is already taken. You can disconnect it first by running: net use Z: /delete