Fix mapped network drives connections in Windows 10

If you are finding that when Windows 10 starts, your mapped network drives are not connected and appear broken with a red “X” as if they were disconnected

Majority of the time, you can just click on them to connect but if you use software that uses the mapped drives, it’s remembering to do this.

Follow these steps to resolve the issue:

Create a Command Prompt script

  • Open Notepad on your computer, then copy and paste the following script in to the blank Notepad file

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

  • Click File > Save As and save the file as MapDrives.cmd

Create a PowerShell script

  • Open Notepad on your computer, then copy and paste the following script in to the blank Notepad file

    $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
    }

  • Click File > Save As and save the file as MapDrives.ps1

Run Scripts on Startup

  • Open File Explorer  and browse to the following location

    %ProgramData%\Microsoft\Windows\Start Menu\Programs\StartUp

  • Copy the MapDrives.cmd file you created before to the StartUp folder

  • Browse to the following location

    %SystemDrive%\Scripts

    TIP: If this folder does not exist, create it in File Explorer quickly using Ctrl + Shift + N keyboard shortcut to create a new folder, and name it Scripts

  • Copy the MapDrives.ps1 file to the Scripts folder

  • Restart your computer and on startup, the scripts should now run and resolve the issue

Was this article helpful?

Related Articles