Connect to a Shared Drive Using the net use Command
The fastest way to access a shared drive from another PC is to use the net use command in Command Prompt. This command creates a connection between your computer and a shared folder on another machine on your network. You do not need special software — Windows includes this tool by default.
Open Command Prompt on your computer. Press Windows key + R, type cmd, and press Enter. At the command line, type the following structure:
net use Z: \\computername\sharename /persistent:yes
Replace Z: with any unused drive letter you want to assign. Replace computername with the actual name or IP address of the computer hosting the shared drive. Replace sharename with the exact name of the shared folder. The /persistent:yes flag keeps the connection active after you restart your computer. If you want the connection to last only for your current session, use /persistent:no instead.
Key Takeaways
- The net use command creates a mapped drive letter that points to a shared folder on another computer, making it appear as a local drive in File Explorer.
- You need the exact computer name or IP address and the exact shared folder name to form the correct network path.
- If the shared folder requires a username and password, add the credentials to your command using the format net use Z: \\computername\sharename password /user:username.
- Use net use without arguments to see all your current mapped drives, and use net use Z: /delete to disconnect a drive when you no longer need it.
Find the Computer Name and Shared Folder Name
Before you run the net use command, you need to know what you are connecting to. On the computer that hosts the shared drive, open File Explorer and look at the folder you want to share. Right-click it and select Properties. Go to the Sharing tab. The name shown under "Share name" is what you type after the backslash in your command.
To find the computer name of the host machine, open Command Prompt on that computer and type hostname. The name that appears is what you use in place of computername in your net use command. Alternatively, you can use the computer's IP address instead of its name. To find the IP address, type ipconfig in Command Prompt and look for the "IPv4 Address" line.
If you do not know which computer hosts the drive, ask the person who set up the share or check your network settings. In File Explorer, click Network in the left sidebar to see all computers on your network.
Add a Username and Password to Your Command
If the shared folder is protected by a password or requires you to log in with a specific account, you must include those credentials in your command. The format changes slightly:
net use Z: \\computername\sharename password /user:username
Type the password in plain text after the share path. Type the username after /user:. If your username includes a domain name (common in office networks), use the format domain\username. For example: net use Z: \\server01\reports mypassword /user:COMPANY\sarah.okafor
After you press Enter, Command Prompt confirms the connection with a message like "The command completed successfully." The drive letter now appears in File Explorer and behaves like any other drive on your computer.
Verify the Connection in File Explorer
Once the net use command runs successfully, open File Explorer. Look at the left sidebar under "This PC." You should see your new mapped drive listed with the letter you assigned. Click it to open the shared folder and access its contents. You can now copy files to and from this drive, create new folders, and work with the shared files as if they were stored locally.
If the drive does not appear when ready, refresh File Explorer by pressing F5. If it still does not show, go back to Command Prompt and type net use with no arguments. This displays all your current mapped drives and their connection status. If your new drive is listed as "OK," the connection is working — the display in File Explorer may just need a moment to update.
Disconnect a Mapped Drive When You No Longer Need It
To remove a mapped drive, open Command Prompt and type:
net use Z: /delete
Replace Z: with the drive letter you want to disconnect. Command Prompt asks for confirmation. Type Y and press Enter. The drive letter is now available for use again, and the connection to the shared folder is closed.
If you set the connection to /persistent:yes, disconnecting it with the /delete command removes it permanently — it will not reconnect automatically after you restart. If you want to keep the connection but temporarily disconnect, you can instead use net use Z: /delete /yes to skip the confirmation prompt.
Troubleshoot Connection Problems
If your command fails with an error message, the most common causes are a typo in the computer name or share name, the host computer being offline, or firewall settings blocking the connection. Double-check the spelling of both the computer name and the share name — they are case-sensitive in the command line.
If you see "The specified computer is not accessible," the host computer may be turned off, not on your network, or blocking file sharing through its firewall. Ask the computer's owner to check that file sharing is enabled in their Windows Firewall settings. On the host computer, open Windows Defender Firewall, click Allow an app through firewall, and make sure File and Printer Sharing is checked for both Private and Public networks.
If you see "Access denied," your username or password is incorrect, or the shared folder does not have permission set for your account. Contact the person who manages the share and ask them to grant your user account access to that folder.
Use the IP Address Instead of the Computer Name
If the net use command does not recognize the computer name, try using the IP address instead. This is more reliable on networks where computer names are not registered properly. The command format stays the same:
net use Z: \\192.168.1.100\sharename /persistent:yes
Replace 192.168.1.100 with the actual IP address of the host computer. To find that IP address, go to the host computer, open Command Prompt, and type ipconfig. Look for the line labeled "IPv4 Address" under your network adapter. Copy that address and paste it into your net use command on your own computer.
Using an IP address works the same way as using a computer name — the connection is just as fast and just as reliable. The only difference is that if the host computer's IP address changes, your mapped drive will stop working and you will need to update the command with the new address.
Frequently Asked Questions
What if I do not know the computer name of the computer hosting the shared drive?
Go to the host computer and open Command Prompt. Type hostname and press Enter. The name that appears is the computer name you need. Alternatively, you can use the IP address instead — type ipconfig and look for the IPv4 Address line.
Can I map a shared drive on a Mac or Linux computer from Windows?
Yes, if the Mac or Linux computer is set up to share files using SMB (Server Message Block). The net use command works the same way. You may need to know the exact username and password for the shared folder, and you should use the IP address instead of the computer name for more reliable connections.
Will my mapped drive stay connected after I restart my computer?
Only if you used /persistent:yes in your net use command. If you used /persistent:no or did not include the flag at all, the connection is lost when you restart. To reconnect, you must run the net use command again.
What drive letters can I use for mapping?
You can use any letter from D through Z. Letters A, B, and C are typically reserved for your hard drives and floppy drive (if present). If a letter is already in use, Command Prompt tells you and you must choose a different one.
How do I see all the shared folders on another computer?
Open Command Prompt and type net view \\computername, replacing computername with the name or IP address of the host computer. This lists all shared folders on that computer. You can then use any of those share names in your net use command.