Windows                                            
** 2/17/25   Networking        
      Windows        
                                               
   
  Home use Cmd / Powershell
  h_hh_ll
  Linux The classic Windows "ghost" connection.
  Windows It happens because Windows is trying to reconnect to the share using the old, failed "handshake" info it has cached in memory,
  Notes while you are simultaneously trying to access the new, working one.
  Template Windows thinks the drive letter (like Z:) or the network path is already "reserved" by a previous failed session.
   
    1 The "Exorcism" (Clear the Ghost Connections) We need to force Windows to forget every active or pending network connection so it can start fresh with your new Samba settings.
    1 Close all File Explorer windows.
    2 Open Command Prompt (or PowerShell) as Administrator.
    3 net use * /delete /y This disconnects all mapped drives and cleared cached sessions. Don't worry, it doesn't delete files; it just "unplugs" the virtual cables.
   
    4 net stop workstation /y Restart the "Workstation" service This resets the Windows networking engine
    net start workstation
   
    2 The "Direct Path" Reconnect Instead of clicking on an old shortcut or a mapped drive, let's use the most direct route to verify the fix.
    1 Win + R
    2 \\100.x.y.z Your Tailscale IP
    3 If it asks for credentials, check the box "Remember my credentials" and enter your mdh username and Samba password.
   
    3 Check Linux Permissions (The "Access Denied" Backup)
    ls -ld /var/www/html your actual shared folder path
   
    4 Optional: Fix the "Local Name in Use" Registry Bug If the error persists after net use * /delete, Windows might be stuck in a registry loop.
    1 Search for Credential Manager in the Start menu. If you find yourself having to do this often, it might be because Windows is trying to use your Windows Login credentials instead of your Samba credentials.
    2 Go to Windows Credentials. To lock in the right "key" forever:
    3 Find any entry for your Debian IP or hostname and Remove it. 1 Open the Start Menu and type Credential Manager.
    Restart your Windows PC 2 Go to Windows Credentials.
    3 Click Add a Windows credential.
    4 Internet or network address: 100.x.y.z (Your Tailscale IP)
    5 User name: mdh
    6 Password: [Your Samba Password]
    This forces Windows to always use the correct "handshake" before it even tries to connect.
   
    Pro-Tips
    Persistent vs. Non-Persistent If you map a drive and want it to stay gone even after a reboot, Windows usually handles that with the /delete command.
    However, if it keeps coming back, it’s often because it was marked as "Persistent" in the registry.
   
    Why the "Local Device Name is already in use" happened It was because Windows had a "Dormant Session."
    Even without a drive letter, Windows keeps a background "pipe" open to the IP address.
    By using the specific /delete command on the IP or the letter, you "flush the pipe" so a new connection can be established.
   
   
    Samba Refresh Script How to use it:
    @echo off Whenever you get that "Device name in use" error or the folder feels "frozen":
    echo Disconnecting old Samba sessions... Right-click the FixSamba.bat file.
    :: Replace Z: with your drive letter, or use the path Select Run as Administrator (this is required to restart the Workstation service).
    net use \\100.x.y.z /delete /y
    echo.
    echo Restarting Workstation service...
    net stop workstation /y
    net start workstation
    echo.
    echo Reconnecting to Debian...
    :: This line attempts to re-open the folder for you
    explorer \\100.x.y.z\YourShareName
    pause
   
   
    The "Last Resort" Windows Bug Windows 11 sometimes refuses to connect to a "Linux-style" SMB share if "Support for SMB 1.0/CIFS File Sharing" is completely uninstalled
    or if "Microsoft Network Client" is disabled on the Tailscale adapter.
    Control Panel > Network and Sharing Center > Change adapter settings
    Right-click the Tailscale adapter > Properties.
    Ensure "Client for Microsoft Networks" is checked.
   
   
   
    Variations of commands used.
    net use N: /delete /y Delete by Drive Letter The "Are you sure?" Prompt: If you want to skip the "Do you want to continue?" message, add the /y (yes) flag at the end:
    net use \\100.x.y.z /delete /y Delete by Network Path
   
    net use List Current Connections It will give you a neat table of everything currently active.
   
    Powershell
    Get-NetConnectionProfile Paste this command to see your network profiles
    Get-NetConnectionProfile -InterfaceAlias "Tailscale" | Set-NetConnectionProfile -NetworkCategory Private # This forces the Tailscale interface to be 'Private', which opens up SMB ports
   
    Note:  If it gives an error, run Get-NetConnectionProfile alone to see if the interface is named something slightly different, like "Tailscale0".