Skip to content

Commit 69b8e7c

Browse files
author
Simonx Xu
authored
Merge pull request #8699 from MicrosoftDocs/v-lianna-patch-5
AB#5401 Update mapped-network-drive-fail-reconnect.md
2 parents ab86263 + fa91905 commit 69b8e7c

File tree

1 file changed

+33
-16
lines changed

1 file changed

+33
-16
lines changed

support/windows-client/networking/mapped-network-drive-fail-reconnect.md

Lines changed: 33 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Mapped network drive may fail to reconnect in Windows 10, version 1809
33
description: An article provides a workaround to resolve mapped network drives not working in Windows 10, version 1809.
4-
ms.date: 01/15/2025
4+
ms.date: 05/07/2025
55
manager: dcscontentpm
66
audience: itpro
77
ms.topic: troubleshooting
@@ -51,9 +51,9 @@ while($True){
5151
foreach( $MappedDrive in $MappedDrives)
5252
{
5353
try {
54-
New-SmbMapping -LocalPath $MappedDrive.LocalPath -RemotePath $MappedDrive.RemotePath -Persistent $True
54+
New-SmbMapping -LocalPath $MappedDrive.LocalPath -RemotePath $MappedDrive.RemotePath -Persistent $True -ErrorAction Stop
5555
} catch {
56-
Write-Host "There was an error mapping $MappedDrive.RemotePath to $MappedDrive.LocalPath"
56+
Write-Host "There was an error mapping $($MappedDrive.RemotePath) to $($MappedDrive.LocalPath)"
5757
}
5858
}
5959
$i = $i - 1
@@ -72,28 +72,45 @@ All workarounds should be executed in standard user security context. Executing
7272
> [!NOTE]
7373
> This workaround works only for the device that has network access at logon. If the device has not established a network connection by the time of logon, the startup script won't automatically reconnect network drives.
7474
75-
1. Copy the script file (MapDrives.cmd) to the following location:
76-
%ProgramData%\\Microsoft\\Windows\\Start Menu\\Programs\\StartUp
77-
2. Copy the script file (MapDrives.ps1) to the following location:
78-
%SystemDrive%\\Scripts\\
79-
3. A log file (StartupLog.txt) will be created in the %TEMP%\\ folder.
80-
4. Log off, and then log back on to the device to open the mapped drives.
75+
1. Copy the script file **MapDrives.cmd** to the following location:
76+
**%ProgramData%\\Microsoft\\Windows\\Start Menu\\Programs\\StartUp**
77+
2. Copy the script file **MapDrives.ps1** to the following location: **%SystemDrive%\\Scripts\\**.
78+
3. A log file **StartupLog.txt** is created in the **%TEMP%\\** folder.
79+
4. Sign out, and then sign in to the device to open the mapped drives.
8180

8281
#### Workaround 2: Create a scheduled task
8382

8483
> [!NOTE]
8584
> A PowerShell window flashes up when the scheduled task runs.
8685
87-
1. Copy the script file MapDrives.ps1 to the following location:
88-
%SystemDrive%\\Scripts\\
86+
1. Copy the script file **MapDrives.ps1** to the following location: **%SystemDrive%\\Scripts\\**.
8987
2. In **Task Scheduler**, select **Action** > **Create Task**.
90-
3. On the **General** tab in the **Create Task** dialog box, type a name (such as *Map Network Drives*) and description for the task.
88+
3. On the **General** tab in the **Create Task** dialog, type a name (such as **Map Network Drives**) and description for the task.
9189
4. Select **Change User or Group**, select a local user or group (such as **LocalComputer\\Users**) and then select **OK**.
9290
5. On the **Triggers** tab, select **New**, and then select **At log on** for the **Begin the task** field.
9391
6. On the **Actions** tab, select **New**, and then select **Start a program** for the **Action** field.
94-
7. Type _Powershell.exe_ for the **Program/script** field.
92+
7. Type **Powershell.exe** for the **Program/script** field.
9593
8. In the **Add arguments (optional)** field, type the following:
96-
_-windowstyle hidden -command .\\MapDrives.ps1 >> %TEMP%\\StartupLog.txt 2>&1_
97-
9. In the **Start in (optional)** field, type the location (_%SystemDrive%\\Scripts\\_) of the script file.
94+
**-windowstyle hidden -command .\\MapDrives.ps1 >> %TEMP%\\StartupLog.txt 2>&1**
95+
9. In the **Start in (optional)** field, type the location of the script file: **%SystemDrive%\\Scripts\\**.
9896
10. On the **Conditions** tab, select the **Start only if the following network connection is available** option, select **Any connection**, and then select **OK**.
99-
11. Log off, and then log back on to the device to run the scheduled task.
97+
11. Sign out, and then sign in to the device to run the scheduled task.
98+
99+
#### Workaround 3: Create a scheduled task for VPN connection Event ID 20225
100+
101+
> [!NOTE]
102+
> Event ID 20225 indicates that a virtual private network (VPN) connection is successfully established.
103+
104+
1. Copy the script file **MapDrives.ps1** to the following location: **%SystemDrive%\\Scripts\\**.
105+
2. In **Task Scheduler**, select **Action** > **Create Task**.
106+
3. On the **General** tab in the **Create Task** dialog, type a name (such as **Map Network Drives**) and description for the task.
107+
4. Select **Change User or Group**, select a local user or group (such as **LocalComputer\\Users**) and then select **OK**.
108+
5. On the **Triggers** tab, select **New**, and then select **On an event** for the **Begin the task** field.
109+
6. Select **Application** from the **Log** dropdown list, type **RasClient** in the **Source** field, and type **20225** in the **Event ID** field. Then, select **OK**.
110+
7. On the **Actions** tab, select **New**, and then select **Start a program** for the **Action** field.
111+
8. Type **Powershell.exe** for the **Program/script** field.
112+
9. In the **Add arguments (optional)** field, type the following:
113+
**-windowsstyle hidden -command .\\MapDrives.ps1 >> %TEMP%\\StartupLog.txt 2>&1**
114+
10. In the **Start in (optional)** field, type the location of the script file: **%SystemDrive%\\Scripts\\**.
115+
11. On the **Conditions** tab, select the **Start only if the following network connection is available** option, select **Any connection**, and then select **OK**.
116+
12. Sign out, and then sign in to the device to run the scheduled task.

0 commit comments

Comments
 (0)