Use the net use command to connect a shared drive from Command Prompt
The fastest way to reach a shared drive from another PC is the net use command in Command Prompt. This command maps a network folder to a drive letter on your computer, so the shared drive appears in File Explorer just like a local hard drive. You type one line, press Enter, and the connection is live — no clicking through menus or hunting for network settings.
The basic command structure is: net use Z: \\computername\foldername /persistent:yes. Replace Z with any available drive letter, computername with the actual name or IP address of the computer hosting the share, and foldername with the name of the shared folder. The /persistent:yes flag keeps the connection active even after you restart your computer.
If the shared drive requires a username and password, add them to the command: net use Z: \\computername\foldername password /user:domain\username /persistent:yes. If you are on a home network without a domain, use just the username: /user:computername\username.
Key Takeaways
- The net use command maps a shared network folder to a drive letter, making it appear in File Explorer on your PC.
- You must know the exact name or IP address of the computer hosting the share and the name of the shared folder.
- Add /persistent:yes to the command so the connection survives a restart.
- If the share is password-protected, include the password and username in the command using the /user: flag.
- Use net use * /delete to remove all mapped drives, or net use Z: /delete to remove a specific one.
Finding the computer name and shared folder name
Before you can connect, you need two pieces of information: the name of the computer hosting the share and the exact name of the folder being shared. On the computer that owns the shared drive, open File Explorer, right-click the folder you want to share, select Properties, then go to the Sharing tab. The folder name appears at the top of the window.
To find the computer name, open Command Prompt on that same computer and type hostname, then press Enter. The name will appear on the next line. Write both down — you will need them exactly as they appear, including capitalization and any numbers or hyphens.
If you do not have direct access to the computer hosting the share, ask the person who manages it for both the computer name (or IP address) and the shared folder name. An IP address works in place of a computer name if the network name is not resolving — use the format \\192.168.1.100\foldername instead of \\computername\foldername.
Opening Command Prompt and entering the net use command
On the computer where you want to access the shared drive, press the Windows key and type cmd. Right-click Command Prompt and select Run as administrator. This gives the command the permissions it needs to create the network connection.
Type your net use command exactly as you have written it, then press Enter. If the command succeeds, you will see a message saying "The command completed successfully." If it fails, Command Prompt will show an error message — common ones are "The network path was not found" (wrong computer name or folder name), "Access denied" (wrong password or username), or "The network resource type is not correct" (the folder is not actually shared).
Once the connection is live, open File Explorer. The shared drive will appear in the left sidebar under "This PC" with the drive letter you assigned. You can now open, read, and edit files on that shared drive as if it were plugged directly into your computer.
Troubleshooting a failed connection
If you see "The network path was not found," the computer name or folder name is wrong. Double-check both against what you wrote down. If you are using a computer name instead of an IP address, try pinging the computer first: type ping computername in Command Prompt. If the ping fails, the computer is not reachable by name — use its IP address instead, or ask your network administrator for the correct name.
If you see "Access denied," the username or password is incorrect, or the folder is not actually shared. Confirm that the folder has sharing turned on by checking its Properties on the host computer. If sharing is on, try the password again — passwords are case-sensitive. If you are still locked out, the host computer may have restricted access to specific users; ask the owner to check the sharing permissions.
If the computer is on a different network or behind a firewall, the connection may time out. In that case, you may need to use a VPN or ask your network administrator to open the necessary ports. For most home networks on the same WiFi or Ethernet, the command works when ready.
Removing a mapped drive when you no longer need it
To disconnect a single mapped drive, type net use Z: /delete (replace Z with the drive letter you want to remove) and press Enter. To remove all mapped network drives at once, type net use * /delete and press Enter when prompted to confirm.
Removing a mapped drive does not delete any files on the shared computer — it only breaks the connection from your PC. The files remain on the host computer and can be accessed again by running the net use command a second time.
Using net use to view all your current connections
To see a list of all mapped drives and network connections on your computer, type net use with no additional parameters and press Enter. The output shows each mapped drive letter, the network path it points to, and whether the connection is persistent. This is useful if you have forgotten which drive letter you assigned to a particular share or want to confirm a connection is still active.
If a connection shows as "Unavailable," the host computer is offline or the network is down. Once the host computer comes back online, the connection will usually restore automatically if you set /persistent:yes.
Frequently Asked Questions
What drive letters can I use?
Any letter from D to Z that is not already in use. A, B, and C are typically reserved for floppy drives and your main hard drive. Type net use to see which letters are already mapped, then pick one that does not appear in the list.
Can I connect to a shared drive on a Mac or Linux computer?
Yes, if the Mac or Linux computer is running a file-sharing service like Samba or NFS. The net use command works the same way — you just need the correct computer name or IP address and the exact path to the shared folder. Ask the person managing that computer for the network address and folder path.
Why does my connection drop after I restart my computer?
You did not include /persistent:yes in your command, or the host computer was offline when you restarted. Add /persistent:yes to make the connection survive restarts. If the host is offline, the connection will restore once it comes back online.
Can I map a shared drive without typing a password every time?
Yes — include the password in the net use command itself using the /user: flag. The connection will then open automatically without prompting. Store this command in a batch file (.bat) if you use it regularly, but keep the file in a find location since it contains your password.
What if the shared folder is on a NAS device instead of a PC?
The net use command works the same way. Use the NAS device's network name or IP address in place of the computer name, and the folder path as it appears in the NAS settings. Check your NAS documentation or ask your network administrator for the correct network address and folder name.
