Accessing a network path from the Windows 10 command line lets you reach shared folders, mapped drives, and remote resources without opening a graphical file browser. These direct methods are useful for troubleshooting, automation, and working in environments where the desktop shell is limited.
This guide outlines three practical approaches that work in Command Prompt and Windows PowerShell, each suited to different scenarios and permission contexts.
| Method | Command | When to use | Credential handling |
|---|---|---|---|
| Command Prompt with net use | net use \\server\share /user:domain\user | Quick interactive access and persistent mappings | Prompts for password or accepts saved credentials |
| PowerShell New-PSDrive | New-PSDrive -Name Z -PSProvider FileSystem -Root \\server\share -Credential (Get-Credential) | Scripting, advanced credential objects, and session reuse | Supports PSCredential and can save to secure strings |
| Cmd with assign access using runas | runas /netonly /user:domain\admin cmd | Access network paths with alternate credentials on the network only | Keeps your local token unchanged, sends different credentials over SMB |
Using net use to open shared network paths
Basic syntax and connection examples
The net use command in Command Prompt is the classic way to connect to a network share from Windows 10. It can create temporary connections and save persistent mappings that survive reboots.
By default, net use connects with your current security context, which works well in domain environments where permissions align with your user account.
Creating mapped drives with PowerShell New-PSDrive
PowerShell advantages for credential and session management
PowerShell provides a more flexible approach with New-PSDrive, letting you map a drive letter to any network path while working directly with credential objects.
This method supports advanced scenarios such as saving encrypted credentials and removing the drive cleanly after your script finishes, reducing leftover connections.
Running as alternate user with runas on the network
Using runas /netonly for delegated access
The runas command with the /netonly switch lets you launch a new command shell where network connections use alternate credentials while your local user context remains unchanged.
This is helpful when you need to access an administrative share or restricted share without running your entire session as that user on the local machine.
SMB direct and UNC path troubleshooting
Checking connectivity when paths fail to open
If your network path does not respond, verify that the server is reachable with Test-Connection and that File and Printer Sharing is enabled on the target network profile.
Confirm that the share name is correct by browsing the share on the server locally, and check event logs for authentication failures or access denied entries related to SMB sessions.
Recommended practices for reliable command line access
- Always test connectivity with ping or Test-Connection before mounting a share
- Use Net Use or New-PSDrive with explicit credentials when required by policy
- Log your commands and errors to a text file for troubleshooting access issues
- Remove persistent mappings that are no longer needed to avoid stale sessions
- Schedule a maintenance script to clean and remap drives after reboots if necessary
FAQ
Reader questions
How do I connect to a network path if my company uses a proxy on outbound SMB traffic?
Use net use with an explicit credential and avoid interactive sessions that time out behind proxy restrictions, or coordinate with network administration to allow SMB over the required ports through the proxy.
What should I do when Windows 10 loses my mapped drive after sleep?
Reconnect automatically with a logon script that runs net use, or switch to a PowerShell New-PSDrive command in your profile that reissues the mount when your session becomes active again.
Can I save credentials securely instead of typing them each time?
Yes, use PowerShell to build a PSCredential object, store it as a secure string in an encrypted file, and then pass it to New-PSDrive so that your network path connects without exposing plain text passwords in scripts.
Will using runas /netonly affect my local machine resources?
No, /netonly changes credentials only for remote network connections, so local processes continue under your own user profile while your network sessions authenticate with the alternate account.