Last Updated on April 28, 2020 by Next Century
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>&1Click 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
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
Restart your computer and on startup, the scripts should now run and resolve the issue