If you have a home or work network set up for your Windows PC, you may also be mapping network shares to drive letters. Mapped drives are very convenient as they allow accessing network files and folders just like a regular local drive. Sometimes in Windows 10, mapped drives do not always automatically and reliably reconnect at logon. Let us see how to fix this issue.
Advertisеment
If a mapped network drive wasn't reconnected, any program that tries to access resources on the mapped network drive fails.
When you create a mapped network drive, there is an option 'Reconnect at logon' which you can check so that every time Windows logs on, they are automatically mounted using the current user's logon credentials.
If you check 'Connect using different credentials', then you can specify a different user name and password.
The problem: When Windows 10 logs on, there is a timing issue which causes it to attempt to map the network drives before the network is available. This results in them being unavailable sometimes. If you press Refresh in Windows Explorer or double click the drive, they instantly become available.
To fix the issue Windows 10 Does Not Reconnect Mapped Network Drives, you need to do the following.
- Paste the following text inside Notepad and save as a *.cmd file.
@echo off :Start timeout /t 5 /nobreak >NUL if exist X:\NUL goto End net use X: \\server\share /USER:domainname\username /PERSISTENT:YES if ERRORLEVEL 1 goto Start :End
Replace the domainname\username portion with the appropriate values.
- In Notepad, press Ctrl + S or execute the File - Save item from the File menu. This will open the Save dialog. There, type or copy-paste the name "reconnect.cmd" including quotes. Double quotes are important to ensure that the file will get the "*.cmd" extension and not *.cmd.txt. You can save the file to any desired location.
- Move the *.cmd file you created to the Startup folder. Refer to the following article: How to add or remove startup apps in Windows 10. In short, press Win + R shortcut keys together and type the following into the Run box:
shell:Startup
This will open your Startup folder in File Explorer.
- Move the reconnect.cmd file there and you are done.
That's it. Many thanks to our reader "Jezze" for sharing this tip.
Support us
Winaero greatly relies on your support. You can help the site keep bringing you interesting and useful content and software by using these options:
If you like this article, please share it using the buttons below. It won't take a lot from you, but it will help us grow. Thanks for your support!
Advertisеment
If you check reconnect at sign in, there’s a noticeable log in loading time even in high end machines. What I do is create a task schedule to map the network drive 1 minute time after log in.
Would you care to share instructions on how to accomplish what you have done with the task scheduler? I tried looking into it and cannot figure it out. Thank you in advance.
Is there a registry settings to increase stock timeout for Mapping Network Drives?
I’ve created a similar solution just check it out, it still needs a bit of work but can be configured and works great for me ;) https://github.com/thexmanxyz/network-share-reconnecter/
Hi Sergey
I am new to this.
I have two network drives that will not reconnect. Your cmd works like a charm. Thanks.
But I am only able to reconnect one of the drives. How will the cmd file look if i want to reconnect both a X: drive as well as a Z: drive?
Regards
Something like this
@echo off
:Start
timeout /t 5 /nobreak >NUL
if exist X:\NUL goto End
net use X: \\server\share /USER:domainname\username /PERSISTENT:YES
if ERRORLEVEL 1 goto Start
:End
:Start2
timeout /t 5 /nobreak >NUL
if exist Z:\NUL goto End2
net use Z: \\server\share2 /USER:domainname\username /PERSISTENT:YES
if ERRORLEVEL 1 goto Start2
:End2
Thanks a lot.
You’re most welcome!
how to get the X: \\server\share /USER:domainname\username /PERSISTENT:YES
I meant to say the domainname and username
Is your PC in a domain? Or it is say your home network?
Thank you. This solved the problem I was having with a scheduled batch file not finding the mapped drive it needed. Worked like a charm.
Hi,
Do I need to tweak this at all to include mapped drive passwords? Or does this script call on the credentials stored locally?
It uses the stored credentials.
I have copied the script and amended the server (naswhite) and username (paul). However when I log in to windows, a command prompt is waiting for me saying:
The password or user name is invalid for \\naswhite\public.
Enter the password for ‘Paul’ to connect to ‘naswhite’:
I have double checked with windows credentials that the username is correct, even down to the case sensitivity. Do you have any idea why this is happening?
Regards,
Chris
If it uses the password from the stored credentials, then that suggests to me that the username in the script doesn’t match the one stored locally. But I’ve checked, three, four times and they are the same. I have no idea what I’ve done wrong
I have exactly the same issue, the credentials are correct, and yet it still prompt the first time
Thank you much Sergey. I had to connect multiple drives and I just replicated the commands following the format..:Start2,3,4 etc. I also found that for drives on the domain that are public I did not need the../USER:domainname\username..line. I hope this helps others.
I prepared a batch file with Net Use commands to make sure the drives are remapped. Appears to work for me.
I read your article with interest. My problem is different: I have a windows 10 pc and a symbology nas on a gigabit Ethernet. There are several shares attached as mapped drives with reconnect at logon ticked.
If the nas boots up after the pc, programs cannot access the network drives until I use windows explorer to open the drives.
Do you know of a way to have the pc automatically access the drives when the nas is booted after the pc?
Hi Sergey
I have a Western Digital “MyCloud” external hard drive networked with my Acer laptop. I use the WD to run scheduled backups of specific Acer data files during the nighttime hours. I have six (6) such scheduled backups and, accordingly, six (6) mapped networked drives on the WD external hard drive.
Until one of the recent updates to Windows 10 these mapped network drives reconnected at startup…now they refuse to do so and I have to reconnect them manually. As a result, I’m looking at your solution. I’m currently on Windows 10 Pro, Version1809, Build 17763.503.
Far as I can tell I’m NOT connected to nor affiliated to a “Domain” so I’m wondering how to modify your Code to accommodate the lack of a “Domain”…
Your Code…
if exist Z:\NUL goto End
net use Z: \\server\share /USER:domainname\username /PERSISTENT:YES
if ERRORLEVEL 1 goto Start
My Code????????????….how to modify??????????
if exist Z:\NUL goto End
net use Z: \\server\share\MYUSERNAME /PERSISTENT:YES
if ERRORLEVEL 1 goto Start
I appreciate your input…John
This worked for me…
@echo off
:Start
timeout /t 5 /nobreak >NUL
if exist Z:\NUL goto End
net use Z: \\WDMYCLOUD\Sytem_Image /PERSISTENT:YES
if ERRORLEVEL 1 goto Start
:End
:Start2
timeout /t 5 /nobreak >NUL
if exist Y:\NUL goto End2
net use Y: \\WDMYCLOUD\Outlook /PERSISTENT:YES
if ERRORLEVEL 1 goto Start2
:End2
:Start3
timeout /t 5 /nobreak >NUL
if exist X:\NUL goto End3
net use X: \\WDMYCLOUD\Acer_New /PERSISTENT:YES
if ERRORLEVEL 1 goto Start3
:End3
:Start4
timeout /t 5 /nobreak >NUL
if exist T:\NUL goto End4
net use T: \\WDMYCLOUD\Predator /PERSISTENT:YES
if ERRORLEVEL 1 goto Start4
:End4
:Start5
timeout /t 5 /nobreak >NUL
if exist N:\NUL goto End5
net use N: \\WDMYCLOUD\FileHistory /PERSISTENT:YES
if ERRORLEVEL 1 goto Start5
:End5
:Start6
timeout /t 5 /nobreak >NUL
if exist M:\NUL goto End6
net use M: \\WDMYCLOUD\Quicken /PERSISTENT:YES
if ERRORLEVEL 1 goto Start6
:End6
Hi John,
For your username, just insert your (NAS) username. you don’t need a domain. if a password is needed, put that with a space after the username. so if your username was Jon and your password was qwerty, the line would read:
net use Z: \\server\share\ /user:Jon qwerty /P:YES
you only need to do the username and the /p (short for persistent) on the first one. the rest will follow the same setting. NOTE – you cant change usernames unless you remove all the shares…
I looks like this will work fine, but what will happen if the network share really doesn’t exists, for example the network is down? Are we getting in an endless loop in this case?
Yep. Exactly.
Ctrl + C will stop it.
This works for the 6 mapped drives I need to connect. But the cmd window opens and it is blank. I close it. Seems ok, but annoying. Is there something I can include to close the window after?
It should exit automatically after mounting the drive.
All the drives show as connected in the file explorer, but the cmd window remains open.
Here is the contents of the file I created, perhaps I did something incorrectly:
@echo off
:Start
timeout /t 5 /nobreak >NUL
if exist X:\NUL goto End
net use X: \\tst02s\Corporate /USER:TST\devinw /PERSISTENT:YES
if ERRORLEVEL 1 goto Start
:End
:Start2
timeout /t 5 /nobreak >NUL
if exist X:\NUL goto End
net use X: \\tst02s\Apps /USER:TST\devinw /PERSISTENT:YES
if ERRORLEVEL 1 goto Start
:End2
:Start3
timeout /t 5 /nobreak >NUL
if exist X:\NUL goto End
net use X: \\tst02s\Shared /USER:TST\devinw /PERSISTENT:YES
if ERRORLEVEL 1 goto Start
:End3
:Start4
timeout /t 5 /nobreak >NUL
if exist X:\NUL goto End
net use X: \\tst02s\TSTracker /USER:TST\devinw /PERSISTENT:YES
if ERRORLEVEL 1 goto Start
:End4
:Start5
timeout /t 5 /nobreak >NUL
if exist X:\NUL goto End
net use X: \\tst02s\Support /USER:TST\devinw /PERSISTENT:YES
if ERRORLEVEL 1 goto Start
:End5
:Start6
timeout /t 5 /nobreak >NUL
if exist X:\NUL goto End
net use X: \\192.168.1.120\TST Tracker Demo Data /USER:TST\devinw /PERSISTENT:YES
if ERRORLEVEL 1 goto Start
:End6
Oh, looking at the example above the one I provided, I think I left of some of the numbers after the goto End and goto Start lines… I will add them in and see if that fixes it.
Yeah, that was it. I changed it to:
@echo off
:Start
timeout /t 5 /nobreak >NUL
if exist X:\NUL goto End
net use X: \\tst02s\Corporate /USER:TST\devinw /PERSISTENT:YES
if ERRORLEVEL 1 goto Start
:End
:Start2
timeout /t 5 /nobreak >NUL
if exist X:\NUL goto End2
net use X: \\tst02s\Apps /USER:TST\devinw /PERSISTENT:YES
if ERRORLEVEL 1 goto Start2
:End2
:Start3
timeout /t 5 /nobreak >NUL
if exist X:\NUL goto End3
net use X: \\tst02s\Shared /USER:TST\devinw /PERSISTENT:YES
if ERRORLEVEL 1 goto Start3
:End3
:Start4
timeout /t 5 /nobreak >NUL
if exist X:\NUL goto End4
net use X: \\tst02s\TSTracker /USER:TST\devinw /PERSISTENT:YES
if ERRORLEVEL 1 goto Start4
:End4
:Start5
timeout /t 5 /nobreak >NUL
if exist X:\NUL goto End5
net use X: \\tst02s\Support /USER:TST\devinw /PERSISTENT:YES
if ERRORLEVEL 1 goto Start5
:End5
:Start6
timeout /t 5 /nobreak >NUL
if exist X:\NUL goto End6
net use X: \\192.168.1.120\TST Tracker Demo Data /USER:TST\devinw /PERSISTENT:YES
if ERRORLEVEL 1 goto Start6
:End6
Works great now, thank you!
Why don’t you try another way? following example:
@echo off
:Start
timeout /t 5 /nobreak >NUL
if not exist Z:\ (net use Z: \\MediaCenter\Anime /PERSISTENT:YES) else ( ECHO “Z:/ Exists”)
if not exist W:\ (net use W: \\MediaCenter\Videos /PERSISTENT:YES) else ( ECHO “W:/ Exists”)
if not exist X:\ (net use X: “\\MediaCenter\TV Shows” /PERSISTENT:YES) else ( ECHO “X:/ Exists”)
if not exist Y:\ (net use Y: \\MediaCenter\SpyPower /PERSISTENT:YES) else ( ECHO “Y:/ Exists”)
if ERRORLEVEL 1 goto Start
:End
I have an issue whereby once i switch on my PC ( it shows not connected to shared network ), once i restart the PC, i am connected again. Why is this happening ? Possible to use your cmd coding to solve my current issue ?
I need a little help?
Client calls in and says that all the shared drives are offline, what would you NOT do?
A nice solution using PowerShell that automatically looks up your mapped drives.
https://support.microsoft.com/en-us/help/4471218/mapped-network-drive-may-fail-to-reconnect-in-windows-10-version-1809
Thanks for sharing!
Great for the help – thank you!!
This is awesome. You’re my hero! I’ve created a looped version instead for my users to make it easier to add/remove drives that they use, and to attempt each drive a few times because our servers are slow.
SET Q_drive=company Q-drive path
SET O_drive=company O-drive path
SET N_drive=company N-drive path
SET K_drive=company K-drive path
:Start
SET current_drive=Q
SET current_path=%Q_drive%
SET next_drive=O
echo Checking network drives…
echo/
:Loop
::Attempt to connect 5 times
FOR /L %%a in (1,1,5) do (
IF exist %current_drive%:\NUL (
echo %current_drive% Drive connected
echo/
goto %next_drive%
)
echo %current_drive% Drive not connected. Attempting to reconnect…
echo Attempt %%a/5
net use %current_drive%: %current_path% /PERSISTENT:YES >NUL 2>&1
timeout /t 3 /nobreak >NUL
)
::if didn’t jump out of loop, then drive not available
echo %current_drive% Drive not available
echo/
goto %next_drive%
:O
SET current_drive=O
SET current_path=%O_drive%
SET next_drive=N
goto Loop
:N
SET current_drive=N
SET current_path=%N_drive%
SET next_drive=K
goto Loop
:K
SET current_drive=K
SET current_path=%K_drive%
SET next_drive=Show_Results
goto Loop
:Show_Results
::delay before closing window to display results
timeout /t 3 /nobreak >NUL
:End