How do I set the Windows network timeout for physically disconnected mapped drive?

28

8

When a network drive (net use) is physically disconnected, Windows Explorer (and other programs) keeps trying to enumerate and/or use it for maybe 60 seconds.

Is there some way to reduce this timeout to maybe 5 seconds?

Just to clarify, I'm not asking about network drives that are automatically disconnected by Windows after a certain period of time, or about automatic reconnections during login.

The question is about this:

Connect a network drive to another computer. Then turn that other computer off. Then try to reconnect the network drive, e.g. by double-clicking in Windows Explorer → very long timeout. How do I reduce this timeout?

Andreas Haferburg

Posted 2012-07-26T07:50:54.727

Reputation: 482

@Ƭᴇcʜιᴇ007 Thanks for the bounty. But I think people still misunderstand. I tried to rephrase the question again to make it clearer. – Andreas Haferburg – 2014-12-16T13:07:25.413

1@AndreasHaferburg No problem, if you've got time to test some of the new answers, that'd be handy. :) – Ƭᴇcʜιᴇ007 – 2014-12-16T13:31:53.803

None of the registry changes suggested in the answers seem to help. I suspect that the timeout we would like to reduce is actually not a SMB timeout, but a more generic TCP/IP timeout (or a combination of several of them). – mivk – 2018-08-19T15:13:29.540

2

You might be looking for this: http://superuser.com/a/332754/124651

– deppfx – 2012-07-26T08:18:10.933

Answers

6

In Windows 7 and Vista mapped network drives will disconnect themselves after a time and show a red cross on the drive icon. You will still be able to click on the drive and see/use the contents but applications that require a network drive will see them as disconnected and will not see files. If you try to disconnect the drive, it will still sit there saying 'Disconnected Network Drive' - the only solution is to reboot. This is because there is a default disconnect time for inactive network connections. To correct this and turn the autodisconnect off do the following:

  1. Open the command prompt as Administrator. To do this, either:

    • go to Start → All Programs → Accessories, right-click "Command Prompt" and select "Start as Administrator", or

    • type cmd into the search box and press Ctrl+Shift+Enter

  2. In the command prompty, type the following:

    net config server /autodisconnect:-1
    
  3. Press Enter

  4. Reboot computer

Your mapped network drives should now stay connected - this is a permanent fix.

Krishna

Posted 2012-07-26T07:50:54.727

Reputation: 77

4This doesn't answer the OPs actual question, original request was misunderstood, see OP's edit. – Ƭᴇcʜιᴇ007 – 2014-12-10T13:45:05.730

I know it is unrelated to OP, but this is exactly what I am looking for, but get access denied. I'm an Admin on my PC. – Rick – 2016-05-01T18:47:01.193

3

Based on http://blogs.msdn.com/b/openspecification/archive/2013/03/27/smb-2-x-and-smb-3-0-timeouts-in-windows.aspx, look like the Windows share timeout is control by "Request Expiration Timer" registry entry.

\HKLM\SYSTEM\CurrentControlSet\Services\LanmanWorkstation\Parameters\
Value type: Dword  
Value name: SessTimeout
Default:    60 seconds (Windows Vista)

It also mentioned this value reduced to 20s in Windows 8 SMB 3.0 for quick failover.

Eric Leung

Posted 2012-07-26T07:50:54.727

Reputation: 302

3Unfortunately, my testing shows that this setting has no effect on the timeout involved in waiting for unavailable network drives. I set it to 5 seconds and I'm still waiting the same ~30 seconds (Windows 7) I was before I set it (and rebooted). – Ƭᴇcʜιᴇ007 – 2014-12-17T16:16:14.413

2

I was having the same problem, but initially it was only around 30 seconds. But when it jumped to around 2 minutes (for some unknown reason), it got so annoying, I had to find a way to solve it.

I have created batch script which tests the network by seeing if it can ping the target machine, if it can, it maps the drives (if unmapped), otherwise, it deletes the mapping.

@echo off

set ipaddr=192.168.5.3

set current=neither

:begin

    set state=down

    for /f %%i in ('ping -n 1 %ipaddr% -w 1000 ^| findstr /C:"Received = 1"') do (
        set state=up
    )

    if not %state% == %current% (
        set current=%state%
        if %state% == up (
            net use R: \\%ipaddr%\archive$
        )
        if %state% == down (
            net use R: /delete /y
        )
    )

    sleep 5

goto begin

That script is then called by a scheduled task, which runs the script every 10 minutes, with a maximum task time of 10 minutes. Although the console window then remains open during this time, I am currently investigating the Network Conditions for this in the scheduler settings, which could be set to create the shares when connected to the network I know the share is on (which would set a flag), and a second script, which would run once ever 5 minutes or so, which if the flag was older than at least however long, it would delete the shares, minimizing console window time.

topherg

Posted 2012-07-26T07:50:54.727

Reputation: 1 004

4Unfortunately I think this kind of solution is about as good as we can expect (still, as of 2014), as least when it comes to logins/Explorer start-up delays caused by the network drives. Have my bounty. Perhaps we can revisit it again in a couple more years. :) – Ƭᴇcʜιᴇ007 – 2014-12-17T16:34:34.113

sleep in your script is not a native command. Better use a vbscript in this case. – Azevedo – 2017-11-08T13:53:29.067

@Ƭᴇcʜιᴇ007 Did you ever find a real solution to this problem? I have a network drive which is often physically powered off, and trying to access it from a client machine results in a frustrating delay. – WackGet – 2019-04-24T01:16:36.403

1

This worked to me on Windows 7 as expected. Also it solves a long wait after login. Pasted here as a .reg file:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\NetworkProvider]
"RestoreConnection"=dword:00000000
"RestoreTimeout"=dword:00000004
"DeferConnection"=dword:00000000

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\LanmanWorkstation\Parameters]
"SessTimeout"=dword:0000000a
"ExtendedSessTimeout"=dword:00000000
"ReconnectTimeout"=dword:00000004

Luis Siquot

Posted 2012-07-26T07:50:54.727

Reputation: 294

This doesn't work on 8.1 – midenok – 2018-11-24T13:50:22.050

1

Your solution is below;

Kill the long "restoring network connections" at logon (defer=ghosted connections)

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\NetworkProvider]

"RestoreConnection"=dword:00000001 ;(0=no attempt, you must click it)

"RestoreTimeout"=dword:00000005

Ghost the connection if not responding within RestoreTimeout

"DeferConnection"=dword:00000001

William Topping

Posted 2012-07-26T07:50:54.727

Reputation: 19

1Any source for where you got this information from, or one that hints at why it might help? – Ƭᴇcʜιᴇ007 – 2014-12-17T16:23:48.197

2Unfortunately, my testing shows that this setting has no effect on the timeout involved in waiting for unavailable network drives. I created the above keys and set their values, but I'm still waiting the same ~30 seconds (Windows 7) I was before I set it (and rebooted). – Ƭᴇcʜιᴇ007 – 2014-12-17T16:31:59.140

1

There is also:[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\LanmanWorkstation\Parameters] "ReconnectTimeout"=dword:00000005 found here: http://www.sevenforums.com/network-sharing/274680-timeout-mapping-network-drives-windows-login.html Setting this entry plus the ones above all to 1 seems to make a huge difference (after reboot). Now everything is fast as expected again.

– kermit – 2014-12-17T17:23:12.780

0

According to this post on Windows7Hacker, fixing this issue on the client side involves a registry edit.

  1. Open the Registry with Regedit.exe
  2. Naviagate to HKLM\SYSTEM\CurrentControlSet\Services\LanmanWorkstation\Parameters
  3. Create a DWORD value named KeepConn and set it to time in seconds to keep the connection alive

For example, I set it to 86400 (one day).

deppfx

Posted 2012-07-26T07:50:54.727

Reputation: 197

1This doesn't answer the OPs actual question, original request was misunderstood, see OP's edit. – Ƭᴇcʜιᴇ007 – 2014-12-10T13:45:39.390

This solution worked for me on Windows 8. – Michael Thessel – 2015-04-10T00:09:02.393

Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference.

– Ivo Flipse – 2012-07-26T09:00:58.023

Also, as a general reminder: Try to make your answers longer than a sentence and add some context please. Explain how the link actually answers the question – it might not be that obvious. – slhck – 2012-07-26T09:03:47.813

@IvoFlipse: Sure. Thanks for the suggesstion. – deppfx – 2012-07-26T12:48:21.867

@slhck: Will keep that in mind. – deppfx – 2012-07-26T12:48:38.013