Network Credentials ใน Windows คืออะไร?
Network Credentials คือ Username และ Password ที่ Windows บันทึกไว้ (Cache) เพื่อใช้เข้าถึงทรัพยากรเครือข่าย (Shared Folder, NAS, Printer, Remote Desktop, VPN) โดยไม่ต้องพิมพ์ซ้ำ ทุกครั้ง เก็บอยู่ใน Windows Credential Manager
เหตุผลที่ต้องการลบ/ปิด Network Credentials
- 🔐 เปลี่ยนรหัสผ่าน Server/NAS แล้ว Windows ยังใช้ Credential เก่า (Error 0x80070035, 0x80004005)
- 🔐 Security: ไม่ต้องการเก็บ Credential บนเครื่อง Shared/Public
- 🔐 Troubleshooting: Connection Issues, "Access Denied", "The specified network password is not correct"
- 🔐 Privacy: ลบข้อมูลก่อนขาย/ส่งซ่อมเครื่อง
วิธีที่ 1: Credential Manager (GUI) - มาตรฐาน/ง่ายที่สุด
- กด Win + S พิมพ์ Credential Manager → Enter
- หรือ: Control Panel > User Accounts > Credential Manager
- เลือกแท็บ Windows Credentials (สำหรับ Network/Server)
- ในส่วน Generic Credentials หรือ Windows Credentials จะเห็นรายการที่บันทึกไว้ (Server Name, IP, User)
- คลิกขยาย (▼) รายการที่ต้องการลบ → คลิก Remove → Yes
- ทำซ้ำสำหรับทุกรายการที่ต้องการลบ
วิธีที่ 2: Command Line (CMD/PowerShell) - เร็ว/Scriptable
CMD (cmdkey.exe):
cmdkey /list
cmdkey /delete:TargetName
cmdkey /delete:* (ลบทั้งหมด - ระวัง!)
PowerShell:
# List
cmdkey /list
# หรือ
Get-StoredCredential
# Remove specific
cmdkey /delete:"ServerName"
# Remove all (Careful!)
Get-StoredCredential | Remove-StoredCredential
วิธีที่ 3: ปิดการบันทึก Credential อัตโนมัติ (Prevent Caching)
A. Group Policy (Pro/Enterprise/Education)
- Win + R →
gpedit.msc - Computer Configuration > Administrative Templates > System > Credentials Delegation
- Enable: Allow Delegating Default Credentials → Set to Disabled
- Enable: Allow Delegating Saved Credentials → Set to Disabled
B. Registry (ทุก Edition - ระวังแก้ Registry)
# Disable Credential Caching for Network Shares
reg add "HKLM\SYSTEM\CurrentControlSet\Services\LanmanWorkstation\Parameters" /v "DisablePasswordChange" /t REG_DWORD /d 1 /f
# Disable Cached Logons (Number of cached logons = 0)
reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v "CachedLogonsCount" /t REG_SZ /d 0 /f
💡 ต้อง Reboot หลังแก้ Registry
วิธีที่ 4: ปิดการถาม Credential ซ้ำๆ (Stop Prompting)
หาก Windows ถาม Username/Password ซ้ำๆ ตอนเข้าถึง Share/NAS:
Option A: Map Network Drive พร้อม Reconnect at Sign-in
- File Explorer > This PC > Map network drive
- Drive: เลือกตัวอักษร > Folder:
\\Server\Share - ✅ Reconnect at sign-in + ✅ Connect using different credentials
- Finish → ใส่ User/Pass → ✅ Remember my credentials
Option B: ปิด Password Protected Sharing (ถ้าไว้ใจเครือข่ายท้องถิ่น)
- Control Panel > Network and Sharing Center > Change advanced sharing settings
- All Networks > Turn off password protected sharing
- Save changes
- ⚠️ ความเสี่ยง: ใครใน LAN เข้าถึง Share ได้โดยไม่ต้อง Password
Option C: ใช้ Local Account แทน Microsoft Account (ลด Sync Credential)
- Settings > Accounts > Your Info > Sign in with a local account instead
คำถามที่พบบ่อย
ลบ Credentials แล้ว ไฟล์บน NAS/Share หายไหม?
ไม่หาย Credentials แค่ "กุญแจ" เปิดประตู ข้อมูลอยู่บน Server/NAS ลบ Credential = ต้องพิมพ์รหัสผ่านใหม่ครั้งหน้า
ทำไมลบแล้ว กลับมาอีก? (Auto-recreate)
- มี Scheduled Task / Service / App ที่ Connect ไป Server นั้นอยู่ (Backup, Sync, Antivirus Update)
- Windows Credential Roaming (Microsoft Account Sync)
- Group Policy: "Allow Delegating Saved Credentials" = Enabled
Credential Manager เปิดไม่ได้ / Error
- Run:
control /name Microsoft.CredentialManager - Check: Credential Manager Service (VaultSvc) Running?
- SFC / DISM Repair:
sfc /scannow+DISM /Online /Cleanup-Image /RestoreHealth
สรุป
ลบ Network Credentials: Credential Manager (GUI) หรือ cmdkey /delete (CMD) ป้องกันการ Cache: Group Policy / Registry หยุด Prompt ซ้ำ: Map Drive + Remember / Turn off Password Protected Sharing (ระวังความปลอดภัย)