How Interesting...
June 21, 2020

Workaround for "Network Drive Not connected" bug in Windows

Posted on June 21, 2020  •  2 minutes  • 390 words
Table of contents

This post describes a work around to automatically connect network drives instead of showing the silly red X through them in explorer on Windows startup. It’s been a bug in Windows for about 15 years, and I believe it’s because of a longstanding race condition when the OS loads its services. In this blog article, we’ll do a little bit of powershell.



The following files should be executed on the regular command prompt - opposed to an elevated permissions command prompt to ensure they run with the same privilege as Windows Explorer.

  1. Create a script file named MapDrives.cmd

Paste the following code into the new file:

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

Paste the following code into the new file:

 3    $error.clear()
 4    $MappedDrives = Get-SmbMapping |where -property Status -Value Unavailable -EQ | select LocalPath,RemotePath
 5    foreach( $MappedDrive in $MappedDrives)
 6    {
 7        try {
 8            New-SmbMapping -LocalPath $MappedDrive.LocalPath -RemotePath $MappedDrive.RemotePath -Persistent $True
 9        } catch {
10            Write-Host "There was an error mapping $MappedDrive.RemotePath to $MappedDrive.LocalPath"
11        }
12    }
13    $i = $i - 1
14    if($error.Count -eq 0 -Or $i -eq 0) {break}
16    Start-Sleep -Seconds 30
  1. Create a startup item

This workaround works only for devices that are already on the network at the time of log-on. If the device has not yet established a network connection by the time of logon, the startup script won’t automatically reconnect network drives. This script does not run continually in the background as that would take up computer resources unnecessarily.

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

Tip 🚀

You can quickly get to the above locations by opening up explorer and copy/pasting the above paths into the navigation bar.


A log file (StartupLog.txt) will be created in the %TEMP% folder.

Finally, log off then back on again and you should correctly observe correctly mapped and accessible drives.

Socials / Links

I tweet tech, bad jokes and silly memes