When you upgrade from Windows 7 to Windows 10, you may notice that the network/mapped drives are randomly disappearing. A logoff/login will fix it temporarily, but what a pain. This is how you permanently fix the vanishing drives.
Group Policy Method
User Configuration > Preferences > Windows Settings > Drive Maps
Change the drive to “Update” in group policy
Registry Method
You cannot use this method to turn off the autodisconnect feature of the Server service. You can only use this method to change the default time-out period for the autodisconnect feature.
- Click Start, click Run, type regedit, and then click OK.
- Locate and then click the following key in the registry:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\lanmanserver\parameters
- In the right pane, click the autodisconnect value, and then on the Edit menu, click Modify. If the autodisconnectvalue does not exist, follow these steps:
- On the Edit menu, point to New, and then click REG_DWORD.
- Type autodisconnect, and then press ENTER.
- On the Edit menu, click Modify.
- Click Hexadecimal.
- In the Value data box, type ffffffff, and then click OK.
The client-side session is automatically disconnected when the idling time lasts more than the duration that is set in KeepConn. Therefore, the session is disconnected according to the shorter set duration value between AutoDisConnect and KeepConn. To change the time-out duration in the client-side during a UNC connection, specify the arbitrary time in KeepConn.
Locate and then click the following key in the registry:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\lanmanworkstation\parameters
Value: KeepConn
Data type : REG_DWORD
Range : 1 to 65535 (sec)
Default value: 600 sec = 10 mins
Command Line Method
If you use this method, you may turn off the auto-tuning feature for the Server service.
To change the default time-out period for the autodisconnect feature of the Server service, open a command prompt, type the following line, and then press ENTER
net config server /autodisconnect:number
…where number is the number of minutes that you want the server to wait before it disconnects a mapped network drive. The maximum value for this command is 65,535.
If you set the autodisconnect value to 0 (zero), the autodisconnect feature is not turned off, and the Server service disconnects mapped network drives after only a few seconds of idle time.
To turn off the autodisconnect feature, open a command prompt, type the following line, and then press ENTER:
net config server /autodisconnect:-1
Failsafe
If all else fails, and the drives are still disconnecting, create a Scheduled Task, pointing to a batch script that checks and reconnects the drive. Add the following code into a netmap.cmd file (copy it to system32), create a Schedule Task, and point to the netmap.cmd file.
@echo off
dir X:\SomeFile.txt
IF %ERRORLEVEL%==1 GOTO MapDrive
exit /b 0
:MapDrive
net use X: /Delete
net use X: \\ShareName\ShareFolder /persistent:yes
:: command line testing
:: dir C:\testss.cmd && echo do not map || echo map drive
Reference
https://www.mcbsys.com/blog/2016/08/windows-10-repeatedly-disconnects-network-drives/