When accessing network shares via UNC paths like \\server\share$
, Windows caches your credentials to streamline future access. While convenient, this becomes problematic when you need to:
- Test different permission levels
- Troubleshoot authentication issues
- Switch domain or local accounts
The most efficient method uses the Windows net use
command. Open Command Prompt as administrator and run:
net use \\somecomputeronmynetwork\somelocation$ /delete
For bulk removal of all cached connections:
net use * /delete /y
Windows 7 stores these credentials in the Credential Manager:
- Open Control Panel > User Accounts
- Click "Manage your credentials"
- Expand "Windows Credentials" section
- Locate entries starting with
Microsoft_WindowsNetwork_
- Remove the relevant credential entry
For administrators managing multiple systems, this PowerShell script clears all network credentials:
$creds = cmdkey /list | Where-Object { $_ -like "*Microsoft_WindowsNetwork_*" } | ForEach-Object {
if ($_ -match "Target: (.*)") {
$matches[1]
}
}
$creds | ForEach-Object {
cmdkey /delete:$_
}
In rare cases where credentials persist, check these registry keys:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones
HKEY_CURRENT_USER\Network\[DriveLetter]
Warning: Always back up the registry before making changes.
After clearing credentials, verify with this PowerShell test:
Test-Path "\\somecomputeronmynetwork\somelocation$" -ErrorAction SilentlyContinue
A successful credential reset will prompt for new authentication.
Windows 7 stores network credentials in the Credential Manager, which you can access through:
Control Panel → User Accounts → Credential Manager
Look for entries under "Windows Credentials" that match your network path (e.g., \\\\somecomputeronmynetwork
). Select the credential and click "Remove".
For power users, you can use the command line to manage credentials:
cmdkey /list
cmdkey /delete:TERMSRV/somecomputeronmynetwork
If you've mapped the drive using NET USE, you can view and delete connections:
net use
net use \\somecomputeronmynetwork\somelocation$ /delete
For persistent credential issues, you might need to edit the registry:
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\MountPoints2]
CAUTION: Always back up the registry before making changes.
Here's a PowerShell script to automate credential removal:
# PowerShell script to remove cached credentials
$target = "\\\\somecomputeronmynetwork"
$creds = cmdkey /list | Where-Object { $_ -match $target }
if ($creds) {
$creds | ForEach-Object {
$cred = $_ -replace ".*Target: (.*?) .*", '$1'
cmdkey /delete:$cred
}
}
- Always use fully qualified domain names (e.g., \\server.domain.com)
- Consider creating a batch file for frequent credential management
- Document your network authentication workflow
If you still can't access with new credentials:
- Reboot the client machine
- Check the server's share permissions
- Verify the account isn't locked out