[
    {
        "role": "user",
        "content": "connections%20made%20with%20net%20use%20...%20%2Fpersistent%3Ayes%20do%20not%20seem%20to%20persist.%20The%20server%20is%20running%20samba.%20perhaps%20there%20are%20options%20to%20make%20persistence%20work%3F"
    },
    {
        "role": "assistant",
        "content": "Here are several things you can try to make `net use \u2026 /persistent:yes` actually *stick* with a Samba share, along with checks for common pitfalls. I'll cover both the Windows side and what to verify/configure on the Samba server.\n\n---\n\n## What Windows Controls\n\n1. **Registry \u2192 SaveConnections**  \n   Windows stores persistent mapped drives under this registry key:  \n   `HKEY_CURRENT_USER\\Software\\Microsoft\\Windows NT\\CurrentVersion\\Network\\Persistent Connections` with the value `SaveConnections = \"Yes\"`. If this is set to \"No\", Windows will *not* restore persistent mappings. ([itprotoday.com](https://www.itprotoday.com/microsoft-windows/how-can-i-stop-users-creating-persistent-connections-?utm_source=openai))\n\n2. **Mapped Drives Stored in HKCU\\Network**  \n   The actual mappings get stored under `HKEY_CURRENT_USER\\Network\\<DriveLetter>` when you map with \u201cReconnect at logon\u201d or `/persistent:yes`. If entries here are missing or corrupted, mappings won\u2019t persist. ([betaarchive.com](https://www.betaarchive.com/wiki/index.php/Microsoft_KB_Archive/102979?utm_source=openai))\n\n3. **Network Availability at Login**  \n   Mapped drives are often restored **before** your network stack is ready. If the Samba server is not yet reachable (due to DNS delays, network drivers, or services not started), then Windows might fail to reconnect. Two commonly helpful settings:\n\n   - Enable the **Group Policy**: *Computer Configuration \u2192 Administrative Templates \u2192 System \u2192 Logon \u2192 \u201cAlways wait for the network at computer startup and logon\u201d*. This forces Windows to delay the user logon until the network and domain stuff are ready. ([irohastack.com](https://irohastack.com/en/mapped-drive-disconnect-after-reboot-2-en/?utm_source=openai))  \n   - Use a **startup script or task** that runs *after* network services are up (maybe delayed by 30\u201360 seconds) to remap the drives. ([irohastack.com](https://irohastack.com/en/mapped-drive-disconnect-after-reboot-2-en/?utm_source=openai))\n\n4. **Credential Storage**  \n   If the Samba share uses different credentials than your Windows login, you need to make sure credentials are properly saved:\n\n   - Use **Credential Manager** \u2192 Windows Credentials to store the Samba credentials.  \n   - Or use `net use \\\\server\\share /user:username password /persistent:yes`, but this might re-prompt unless credentials are cached.  \n   - Tools like `cmdkey /add:\"server\" /user:\"username\" /pass:\"password\"` help cache credentials to avoid re-entry. ([reddit.com](https://www.reddit.com/r/selfhosted/comments/1logsai?utm_source=openai))\n\n5. **SMB Protocol Version & Security Settings**  \n   Occasionally, Windows may refuse connections on first login if there\u2019s a mismatch of the minimum/maximum SMB version, or if your Samba server requires signing/encryption that isn\u2019t agreed upon immediately. Ensuring Samba supports SMB2/SMB3 and doesn\u2019t force legacy-only or deprecated settings improves reliability. ([reddit.com](https://www.reddit.com/r/selfhosted/comments/18xanch?utm_source=openai))\n\n---\n\n## What You Can Configure on the Samba Server\n\nWhile most persistence issues are on the Windows side, certain Samba settings can exacerbate problems:\n\n- Make sure the share is reachable by IP and/or DNS name early on in the boot process. If your server waits for network to come up, delay in Samba startup could cause Windows to not see it in time.\n\n- Permissions: ensure that valid users and authentication mechanisms used by Samba are set properly (`security = user`) and that the share allows the intended user to connect. If Samba rejects authentication at reconnect, Windows will drop the mapping.  \n\n- Join Samba to a domain (if you have one) or ensure consistency of user accounts/passwords between Windows and Samba if using local accounts.\n\n---\n\n## Step-by-Step Checklist\n\nHere\u2019s a practical checklist to follow:\n\n| Item | Action | Why It Helps |\n|---|---|---|\n| 1 | Check **SaveConnections** registry value in HKCU under `Persistent Connections`. Set to \u201cYes\u201d. | Enables Windows to save persistent mapping info. |\n| 2 | Map the drive **with** `/persistent:yes`, including `/user:` if needed. Use IP or nickname that you trust resolves promptly. | Ensures the mapping is marked persistent and that Windows knows how to resolve the target during reconnect. |\n| 3 | Store Samba credentials via Credential Manager or `cmdkey`. | Avoids needing manual input on reboot. |\n| 4 | Enable \u201cAlways wait for the network at computer startup and logon\u201d GPO (if domain or local policy allows). | Makes sure the share is reachable before Windows tries to reconnect. |\n| 5 | If not domain, delay drive mapping via a logon script or scheduled task delayed after login. | Gets around cases where mapping happens too early. |\n| 6 | Double-check Samba's smb.conf: ensure compatible SMB protocol versions, correct authentication, valid users, correct shares. | Ensures server side accepts the reconnect. |\n\n---\n\nIf you like, I can walk you through adjusting Samba's config (`smb.conf`) specifically to support this, or show actual registry entries. Do you want to go into that?"
    }
]