HomeWindows 7 Tutorial

Automatically reconnect to shared drive in Windows 7/8/10

1Auto reconnect to shared/network drive - Step 1

Especially on a server, automatically reconnecting to a shared / network drive when Windows starts can be crucial. On a regular PC (client computer on the local network), just clicking on the drive will reconnect it within seconds, but not automatically - and not always. That's why you get error messages like "An error occurred while reconnecting to ... The network path was not found ... This connection has not been restored" when you try to access a mapped drive.

2Auto reconnect to shared/network drive - Step 2

If you haven't mapped the drive from a shared/network folder already, start by doing that to establish the initial connection: map a drive in Windows 7/8/10.

In this tutorial, I'll want to automatically restore the connection to a folder on \\Remote-PC-Name\Folder-1\Folder-2 (a shared folder on my local area network - LAN), which I already mapped to the letter "S:\" (as in Shared drive).

3Auto reconnect to shared/network drive - Step 3

We're going to tackle this issue by creating a batch file: a ".bat" file contains saved command line instructions that you normally would enter in a DOS window (command prompt). It sounds complicated, but it's not. If you've ever saved a text file in Notepad, half the work is already mastered, so no worries :)

Start by opening Notepad, or a plain-text / programming editor of your choice.

4Auto reconnect to shared/network drive - Step 4

Once in Notepad, type the following, all on a single line:
subst S: "\\Remote-PC-Name\Folder-1\Folder-2"

Replace "S:" with the drive letter you want to use, and everything that comes after it by the actual network path of the shared folder. Use "double quotes" around the path if it contains any spaces. Otherwise, the quotes are optional.

5Auto reconnect to shared/network drive - Step 5

Now save the text file under the name you want. To be on the safe side (I don't know if you have Windows set to show file extensions or not), start with double-quotes, type a file name, a period, and bat at the end (the file extension for batch files). Close with another double-quote, as shown on the screenshot. That ensures that the file will be saved as a batch file (*.bat), and not a plain text file (*.txt). Move the file to the target PC's startup folder (next step).

*Auto reconnect to shared/network drive - Step 6

Bonus Tip: placing shortcuts in the startup folder.

On the target PC, hold down the WinKey (key that shows a Windows logo) and hit the letter "R". That will open the Run dialog. Type shell:startup and hit Enter to open the current user's startup folder in Windows Explorer. Any file or shortcut in that folder will automatically be launched when that user logs on.