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

แก้ Mapped Network Drives ไม่ทำงานใน Windows 10 v1809+ (Script/Task Scheduler/GPO)

Mapped Network Drives ใช้เข้าถึง Drive บนคอมพิวเตอร์อื่น/Storage ภายนอก แต่ Windows 10 v1809+ มักมีปัญหา: แสดง Red X, Unavailable ใน CMD, หรือ Notification แจ้งเตือน อาจใช้เวลานานเกินไปในการเชื่อมต่อ แนะนำรัน Script ตอน Logon

Workarounds สำหรับ Mapped Drives ไม่ทำงาน

แต่ละวิธีเหมาะสถานการณ์ต่างกัน (Network at Logon, GPO Settings) เลือกที่เหมาะกับคุณ

สร้าง Scripts (2 ไฟล์)

MapDrives.cmd (รันที่ CMD ธรรมดา):

PowerShell -Command "Set-ExecutionPolicy -Scope CurrentUser Unrestricted" >> "%TEMP%\StartupLog.txt" 2>&1
PowerShell -File "%SystemDrive%\Scripts\MapDrives.ps1" >> "%TEMP%\StartupLog.txt" 2>&1

MapDrives.ps1 (PowerShell Script):

$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 "There was an error mapping $MappedDrive.RemotePath to $MappedDrive.LocalPath"
    }
  }
  $i = $i - 1
  if($error.Count -eq 0 -Or $i -eq 0) {break}
  Start-Sleep -Seconds 30
}

เก็บทั้ง 2 ไฟล์ในโฟลเดอร์เดียวกัน

วิธีรัน Script ให้เชื่อม Mapped Drives อัตโนมัติ

1. Startup Item (ต้องมี Network ตอน Logon)

  • Copy MapDrives.cmd ไป %ProgramData%\Microsoft\Windows\Start Menu\Programs\StartUp
  • Copy MapDrives.ps1 ไป %SystemDrive%\Scripts\
  • จะสร้าง Log: %TEMP%\StartupLog.txt Logout/Login ใหม่

2. Scheduled Task (แนะนำ)

แก้ Mapped Network Drives ไม่ทำงานใน Windows 10 v1809+ (Script/Task Scheduler/GPO)

  1. Copy MapDrives.ps1 ไป %SystemDrive%\Scripts\
  2. เปิด Task Scheduler > Action > Create Task
  3. General: ชื่อ, Description, Change User or Group เลือก User/Group, Run with highest privileges
  4. Triggers: New > At Logon
  5. Actions: New > Start a Program:
    • Program: Powershell.exe
    • Arguments: -windowsstyle hidden -command .\MapDrives.ps1 >> %TEMP%\StartupLog.txt 2>&1
    • Start in: %SystemDrive%\Scripts\
  6. Conditions: Start only if network connection available > Any connection
  7. แก้ Mapped Network Drives ไม่ทำงานใน Windows 10 v1809+ (Script/Task Scheduler/GPO)

Reboot/Logoff แล้ว Login ใหม่ Task จะทำงาน

3. Group Policy Settings (ถ้า Mapped Drives มาจาก GPO)

แก้ Mapped Network Drives ไม่ทำงานใน Windows 10 v1809+ (Script/Task Scheduler/GPO)

เปลี่ยน Action ของ Drive Maps เป็น Replace (ลบ Drive เก่า สร้างใหม่ทุก Logon) — Settings บน Mapped Drive ที่ตั้งผ่าน GPO จะหายทุกครั้ง หากไม่ได้ รัน gpupdate /force

วิธีใดวิธีหนึ่งจาก Microsoft ควรช่วยแก้ปัญหาได้ บอกเราได้ว่าวิธีไหนใช้ได้

แก้ Mapped Network Drives ไม่ทำงานใน Windows 10 v1809+ (Script/Task Scheduler/GPO)