guide · static export
PC · networking

Map a Network Drive That Survives a Reboot

A drive letter that disappears at every logon usually has no stored credential or no persistent flag. Store the credential in Credential Manager, map with net use /persistent:yes and check the registry key Windows really uses.

by@guidox updated:10/31/26 time:15 min level:Beginner tested on:Windows 11 24H2 works on:Windows 10, Windows 11, Windows Server 2019 tools:PowerShell, Credential Manager
TL;DR

Use **cmdkey** to store the credential, then **net use Z: \\server\share /persistent:yes**. The pair is what makes the letter return after a reboot, and **HKCU\Network\Z** is the key Explorer reads at sign-in.

Before you start

Requirements

  • A reachable share and a valid account for it
  • A free drive letter
  • 15 minutes
Step by step

Instructions

01

Prove the share answers before mapping it

**Test-Path** on the UNC path fails fast and tells you whether the problem is the network or the mapping. **net view** lists what the server publishes, which catches a mistyped share name.

net view \\nas01
Test-Path \\nas01\projects
Resolve-DnsName nas01
02

Store the credential once, not per session

**cmdkey** writes the password into the user's credential vault, so no prompt appears at sign-in. The target name must match the server exactly as the mapping uses it.

cmdkey /add:nas01 /user:nas01\backup /pass:Str0ngPass
cmdkey /list:nas01
03

Map with a fixed letter and the persistent flag

Without **/persistent:yes** the mapping lives only in the current session. **Get-SmbMapping** shows the status and whether the entry is remembered.

net use Z: \\nas01\projects /persistent:yes
Get-SmbMapping
Get-ChildItem Z:\ | Select-Object -First 5 Name
04

Read the key Windows uses at logon

A persistent mapping is a value under **HKCU\Network** named after the drive letter. If the key is missing, the mapping was created with the persistent flag off, no matter what the dialog claimed.

Get-ItemProperty HKCU:\Network\Z
Get-ChildItem HKCU:\Network | Select-Object PSChildName,RemotePath
tipThe **Reconnect at sign-in** checkbox in Explorer writes exactly this key. Both routes end in the same place.
05

Fix the drive that only appears after a click

Elevated processes get a separate logon session and cannot see mappings made by the normal one. **EnableLinkedConnections** lets both share the same drive letters, which is the usual cure for a red cross on boot.

reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" /v EnableLinkedConnections /t REG_DWORD /d 1 /f
taskkill /f /im explorer.exe
start explorer.exe
⚠ warningThe registry value applies to every user on the machine. Remove it if you rely on users having separate drive letters.
06

Remove a mapping without leaving a ghost

**net use /delete** drops the letter and the stored entry; the credential stays in the vault until it is deleted separately. A ghost letter usually means the persistent value survived.

net use Z: /delete /y
cmdkey /delete:nas01
Get-SmbMapping
Get-ChildItem HKCU:\Network -ErrorAction SilentlyContinue
Troubleshooting

Common issues

The drive has a red cross on every boot

The credential is missing or the server answers after Explorer starts. Sign in, open the drive once, and confirm cmdkey /list:nas01 returns an entry with the right user.

Windows asks for the password at every sign-in

The stored target name does not match. cmdkey stores per server, so nas01 and nas01.domain.local are two entries; map with the name you stored.

Error 67 or 53 when mapping

Network path not found. Check Resolve-DnsName, then try the IP address to rule out name resolution before blaming the share.

The mapping works in Explorer but not in an elevated shell

This is the linked-connection split. Set EnableLinkedConnections as in step 5 and restart Explorer.

FAQ

Frequently asked

Is a mapped drive different from Add a network location?

Yes. A mapping gives a drive letter and lives in the session; a network location is a shortcut that survives without a letter but cannot be used by older programs that expect a path like Z:\.

Do other users on the PC see the mapping?

No. HKCU\Network and the credential vault are per user. Each account needs its own cmdkey entry and its own net use call.

Can I use the UNC path instead of a letter?

Always. A UNC path needs no mapping at all and works in scripts without any logon state, which is why scheduled tasks should use \\server\share rather than Z:\.

How to undo this

Run net use Z: /delete /y to drop the letter and cmdkey /delete:nas01 to remove the saved credential. Delete the EnableLinkedConnections value if you added it, then restart Explorer.

Changelog · 1 entry
  1. 2026-10-31
    First version
Interactive version: checklist, feedback, related guides →

Free · no account needed · tracks your progress