Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> ระบบ >> Windows 10

Could not Reconnect All Mapped Network Drives บน Windows 10

Windows 10 Build ล่าสุดมี Bug ทำให้ Mapped Network Drives อาจล้มเหลวในการ Reconnect อัตโนมัติตอน Windows Startup หลังจาก Log In ผู้ใช้จะเห็น Big Red Cross บน Icons ของ Mapped Network Drives ทั้งหมดใน File Explorer หากคุณรันคำสั่ง net use ใน Command Prompt จะเห็น Status Unavailable หน้าทุก Mapped Drives ทั้ง User-mapped Network Drives และ GPO-mapped Drives ไม่ Reconnect อัตโนมัติ

ปัญหานี้ปรากฏครั้งแรกบน Windows 10 1809 แต่เกิดขึ้นใน Builds ใหม่กว่ารวมถึง Windows 10 2004 ด้วย

Mapped Network Drives ไม่ Reconnect ใน Windows 10

Windows 10 เพราะบางเหตุผลหยุด Auto-map Network Drives หลัง Restart Device Mapped Network Drives แสดงใน File Explorer แต่คุณไม่สามารถเชื่อมต่อกับมันได้

Could not Reconnect All Mapped Network Drives บน Windows 10

ในกรณีนี้ Pop-up Window จะปรากฏใน Notification Area พร้อม Alert:

Could not reconnect all network drives. Click here to check the status of your network drives.

Could not Reconnect All Mapped Network Drives บน Windows 10

ปัญหานี้เกิดกับ Mapped Drives ที่เชื่อมต่อจาก NAS Devices และ Shared Folders บน Windows / Linux Computer อื่นๆ Bug นี้ปรากฏครั้งแรกใน Windows 10 Version 1809 และตาม Microsoft ถูกแก้ไขโดย Update KB469342 ที่ Release วันที่ 5 ธันวาคม 2018 (แก้ไขปัญหาที่อาจทำให้ Mapped Drives ล้มเหลวในการ Reconnect หลัง Start และ Log On Windows Device) แต่ปัญหายังคงเกิดใน Windows 10 Builds ใหม่ๆ

คุณสามารถ Download และ Install Update ด้วยตนเองจาก Microsoft Update Catalog ได้

Microsoft ยังเสนอ Workaround สำหรับปัญหาการกู้คืนการเชื่อมต่อ Mapped Network Drives (ดู KB4471218 — Mapped network drive may fail to reconnect in Windows 10, version 1809) โดยเสนอให้รัน PowerShell Script ตอน User Logon หาก Network Drives เชื่อมต่อผ่าน Group Policy คุณต้องเปลี่ยน GPO Settings

Auto Reconnect Mapped Network Drives ด้วย PowerShell

มาดูวิธีใช้ PowerShell Script เพื่อ Auto Reconnect Mapped Network Drives เมื่อ User Logon เข้า Windows

รัน notepad.exe คัดลอก PowerShell Code ต่อไปนี้ วางไว้ และบันทึกไฟล์ที่ C:\PS Directory เป็น MapDrives.ps1:

$i=3
while($True){
$error.clear()
$MappedDrives = Get-SmbMapping |where -property Status -Value Unavailable -EQ | select LocalPath,RemotePath
foreach( $MappedDrive in $MappedDrives)
{
try {
New-SmbMapping -LocalPath $MappedDrive.LocalPath -RemotePath $MappedDrive.RemotePath -Persistent $True
} catch {
Write-Host "Shared folder connection error: $MappedDrive.RemotePath to drive $MappedDrive.LocalPath"
}
}
$i = $i - 1
if($error.Count -eq 0 -Or $i -eq 0) {break}
Start-Sleep -Seconds 30
}

Could not Reconnect All Mapped Network Drives บน Windows 10

Script นี้เลือก Mapped Drives ที่เข้าถึงไม่ได้ทั้งหมดและพยายาม Reconnect ใน Persistent Mode

สร้างไฟล์ Script MapDrives.cmd อีกไฟล์ด้วย Code ต่อไปนี้:
PowerShell -Command "Set-ExecutionPolicy -Scope CurrentUser Unrestricted" >> "%TEMP%\StartupLog.txt" 2>&1
PowerShell -File "%SystemDrive%\PS\MapDrives.ps1" >> "%TEMP%\StartupLog.txt" 2>&1

Code นี้ช่วยให้คุณ Bypass PowerShell Execution Policy และรัน PS1 Script ที่อธิบายไว้ข้างต้น คุณสามารถวาง Batch File นี้ใน Startup ของ User โดยการ Copy MapDrives.cmd ไปที่โฟลเดอร์ %ProgramData%\Microsoft\Windows\Start Menu\Programs\StartUp

คุณยังสามารถสร้าง Scheduled Task ให้รัน MapDrives.cmd ตอน User Logon ได้ สามารถสร้าง Scheduler Task ด้วย PowerShell หรือจาก Task Scheduler GUI Console (Taskschd.msc)

  1. สร้าง Task ใหม่ ระบุชื่อ (reMapNetworkDrives) เลือกให้ Task รันบน behalf ของ Group Builtin\Users;
    Could not Reconnect All Mapped Network Drives บน Windows 10
  2. บนแท็บ Triggers ให้เลือกว่ Task ควร Run เมื่อ User ใด User หนึ่ง Log On เข้าระบบ (At logon -> Any user);
  3. บนแท็บ Actions ในฟิลด์ Program/script ระบุ Path ไปยัง MapDrives.cmd File;
  4. บนแท็บ Conditions คุณสามารถ Enable Options Network -> Start only if the following network connection is available -> Any Connection;
    Could not Reconnect All Mapped Network Drives บน Windows 10
  5. Reboot Computer หรือ Logoff/Logon ภายใต้ User Account ของคุณ เมื่อ User Log In Script ควรจะ Run ซึ่งจะ Re-create Mapped Drive Connections ทั้งหมด

โปรดทราบว่าโดยค่าเริ่มต้น Network Drives ที่เชื่อมต่อใน Elevated Mode ไม่พร้อมใช้งานใน Normal Mode และในทางกลับกัน แต่คุณสามารถแก้ไขได้ – ดูบทความ Mapped drives are not available from the elevated apps

Automatic Reconnection of Mapped Drives ผ่าน GPO

หากคุณ Map Network Drives ให้ Users โดยใช้ Domain Group Policies คุณต้องเปลี่ยน Policy Settings เพื่อเชื่อมต่อ Drives ให้ถูกต้อง

เปิด GPO ที่เชื่อมต่อ Drives และใน Section User Settings -> Preferences -> Windows Settings -> Drive Maps หา Network Drive Assignment Policy (Policies) ของคุณและเปลี่ยน Action Type จาก Update เป็น Replace

Could not Reconnect All Mapped Network Drives บน Windows 10

หลังจาก Update Group Policy Settings บน Clients Mapped Network Drives จะถูกลบและ Reconnect เมื่อ User Logon

Mapped Network Drive May Fail to Reconnect บน Windows 10 2004 (20H2)

ปัญหาการ Map Network Drives ยังเกิดขึ้นบน Windows 10 2004 (Build 20H2) ปัญหาเกิดกับ Network Drives ที่เชื่อมต่อจาก Legacy Network Devices ที่รองรับแค่ SMBv1 Protocol (Windows XP/2003, Old NAS Devices)

เพื่อแก้ไขปัญหานี้ คุณต้องเพิ่ม Parameter ProviderFlags=1 ใน User Registry สำหรับ Mapped Network Drive แต่ละ Drive

ตัวอย่าง: หาก User มี Network Drive U: ที่ Map ใน Session ไปที่ Registry Key HKEY_CURRENT_USER\Network\U สร้าง DWORD ชื่อ ProviderFlags ค่า 1

หรือรันคำสั่ง:

REG ADD "HKCU\Network\U" /v "ProviderFlags" /t REG_DWORD /d "1" /f

Could not Reconnect All Mapped Network Drives บน Windows 10

Delay Mapping Network Drives ใน Windows ผ่าน GPO

Windows อาจพยายาม Reconnect Network Drives ตอน User Logon ก่อนที่ Network Interface จะ Initialize เสร็จสิ้น เพื่อป้องกัน Mapped Drives จากการเชื่อมต่อจนกว่า Network จะ Enabled สมบูรณ์ คุณสามารถกำหนด Group Policy Setting เฉพาะเจาะจงได้

คุณสามารถกำหนด Setting นี้ผ่าน Local Group Policy Editor (gpedit.msc) หรือจาก Domain GPO Editor (gpmc.msc) ไปที่ Computer Configuration -> Administrative Templates -> System -> Logon และ Enable Policy Always wait for the network at computer startup and logon

Could not Reconnect All Mapped Network Drives บน Windows 10

Reboot คอมพิวเตอร์ของคุณ

คุณยังสามารถแก้ไขปัญหานี้ได้หากคุณแค่รอ 15 วินาทีหลัง Boot Computer (หรือออกจาก Hibernation/Sleep Mode) ก่อน Log In เวลานี้จะเพียงพอสำหรับ Windows ในการ Initialize Network

Disable Could Not Reconnect All Network Drives Notification

หากคอมพิวเตอร์ของคุณไม่อยู่บน Corporate Network (Network Drives ไม่พร้อมใช้งานโดยออกแบบ) และคุณรำคาญกับ Notification "Could not reconnect all network drives" ทุกครั้งที่ Windows Boot คุณสามารถปิดมันได้

ไปที่ Registry Key HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\NetworkProvider และสร้าง DWORD Parameter ใหม่ชื่อ RestoreConnection ค่า 0

Could not Reconnect All Mapped Network Drives บน Windows 10