Windows OS Hub
  • Windows Server
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
    • Windows Server 2012 R2
    • Windows Server 2008 R2
    • SCCM
  • Active Directory
    • Active Directory Domain Services (AD DS)
    • Group Policies
  • Windows Clients
    • Windows 11
    • Windows 10
    • Windows 8
    • Windows 7
    • Windows XP
    • MS Office
    • Outlook
  • Virtualization
    • VMWare
    • Hyper-V
    • KVM
  • PowerShell
  • Exchange
  • Cloud
    • Azure
    • Microsoft 365
    • Office 365
  • Linux
    • CentOS
    • RHEL
    • Ubuntu
  • Home
  • About

Windows OS Hub

  • Windows Server
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
    • Windows Server 2012 R2
    • Windows Server 2008 R2
    • SCCM
  • Active Directory
    • Active Directory Domain Services (AD DS)
    • Group Policies
  • Windows Clients
    • Windows 11
    • Windows 10
    • Windows 8
    • Windows 7
    • Windows XP
    • MS Office
    • Outlook
  • Virtualization
    • VMWare
    • Hyper-V
    • KVM
  • PowerShell
  • Exchange
  • Cloud
    • Azure
    • Microsoft 365
    • Office 365
  • Linux
    • CentOS
    • RHEL
    • Ubuntu

 Windows OS Hub / Windows 10 / Slow Access to Shared Folders and Network Drives in Windows

November 10, 2022 PowerShellWindows 10Windows 7Windows Server 2016

Slow Access to Shared Folders and Network Drives in Windows

Our users are complaining about very slow network performance when opening or saving files to a network shared folder in Windows. When a user opens a shared folder via a UNC path, or via a drive letter (if the shared folder is mapped as a network drive), its contents are displayed only in 10-60 seconds. When creating new files in a network folder, they are also not displayed immediately, but with a long delay after 3-4 minutes (even if you update the folder contents with the F5 key). However, if you manually specify the full file name via a UNC path (\\lon-file-srv1\public\new_file.docx), it will open, although it won’t be visible in the File Explorer.

Slow access to network drive or folder from Windows

Windows uses a special Network Redirector component when access shared files and other network resources on remote computers. Starting with SMB v2.x (see the table with Server Message Block protocol versions), the Network Redirector uses a caching mechanism when accessing shared folders and files over the network. This reduces the traffic and the number of SMB requests between the client and the server (especially effective on in slow and unreliable networks). By default, this cache is cleared every 10 seconds.

If you are experiencing slow access to a network share on a Windows client device, you can try disabling the SMB metadata caching on the client side or in the shared folder settings.

You can disable SMB caching in the shared folder settings. Open the properties of the shared folder, and go to the Sharing tab -> Advanced Sharing -> Caching. Select the second option “No files or programs from the shared folder are available offline”.

disable network share caching in windows

Or use the PowerShell command from the built-in SMBShare module:

Set-SMBShare -Name MySharedDocs -CachingMode None

This will disable both caching and offline access to this shared folder (see the article on using offline files in Windows).

There are three registry parameters that manage network shared folder cache settings on the SMB client side. Microsoft states that the default values for these registry options provide the best performance for most environments. The SMB cache settings are located under the registry key HKLM\System\CurrentControlSet\Services\LanmanWorkstation\Parameters.

  • DirectoryCacheLifetime is the lifetime of the shared folder metadata cache (10 seconds by default);
  • FileNotFoundCacheLifetime – “File not found” response cache (5 seconds);
  • FileInfoCacheLifetime – the time of keeping the cache with the file info (10 seconds).
You can find information about these registry settings in the article on optimizing Windows file server settings: https://docs.microsoft.com/en-us/windows-server/administration/performance-tuning/role/file-server/

By default, the cache lifetime for an SMB share folder is only 10 seconds. When a client refresh the contents of a shared folder, the result of the last update is stored by the client for 10 seconds. When accessing this network share, all applications first try to use this cache.

In some cases, the mechanism for caching data in SMB folders doesn’t work correctly (most often this happens with network folders/drives containing thousands of files and folders). In this case, users may experience significant delays when opening, viewing, and creating files in shared folders.

You can disable caching for SMB folders. To do this, create a new DWORD parameter under the HKLM\System\CurrentControlSet\Services\LanmanWorkstation\Parameters registry key with the name DirectoryCacheLifetime and a value of 0. Also set the values of the FileInfoCacheLifetime and FileNotFoundCacheLifetime parameters to 0. You can create this registry parameters using regedit.exe or with the New-ItemProperty PowerShell cmdlet:

$regpath= "HKLM:\System\CurrentControlSet\Services\LanmanWorkstation\Parameters"
$Name1 = "DirectoryCacheLifetime"
$Name2 = "FileInfoCacheLifetime"
$Name3 = "FileNotFoundCacheLifetime"
New-ItemProperty -Path $regpath -Name DirectoryCacheLifetime -Value 0 -PropertyType DWORD -Force | Out-Null
New-ItemProperty -Path $regpath -Name FileInfoCacheLifetime -Value 0 -PropertyType DWORD -Force | Out-Null
New-ItemProperty -Path $regpath -Name FileNotFoundCacheLifetime -Value 0 -PropertyType DWORD -Force | Out-Null

DirectoryCacheLifetime registry parameter can fix slow access to files on shared folders

You must restart your computer for the settings to take effect. If these parameters need to be applied to multiple domain computers, you can use the GPO to deploy the registry settings.

Disabling network folder caching increases network traffic and reduces file-server performance.

You can also use the Set-SmbClientConfiguration cmdlet to fine-tune the SMB client:

Set-SmbClientConfiguration -DirectoryCacheLifetime 0
Set-SmbClientConfiguration -FileInfoCacheLifetime 0
Set-SmbClientConfiguration -FileNotFoundCacheLifetime 0

You can list the current caching settings for the Windows SMB client with PowerShell:

Get-SmbClientConfiguration| select *cache*

DirectoryCacheEntriesMax : 16
DirectoryCacheEntrySizeMax : 65536
DirectoryCacheLifetime : 0
FileInfoCacheEntriesMax : 64
FileInfoCacheLifetime : 0
FileNotFoundCacheEntriesMax : 128
FileNotFoundCacheLifetime : 0

powershell get-smbclientconfiguration cachelifetime

After that, all changes in the shared will be immediately displayed on the client (the contents of the folder are refreshed each time it is accessed and the local cache is not used).

There are several other reasons for poor network performance of shared folders, or when the contents of folders may appear slowly:

  • Enabling the “Access-based Enumeration (ABE)” option in the shared folder settings can lead to a slow update of the list of files in a shared folder with a large number of objects;
  • You may experience slow network speed on Hyper-V virtual machines running on Windows Server 2019 (compared to Windows Server 2016/2012R2);
  • Try to disable the legacy NetBIOS protocol in the properties of your TCP/IPv4 connection on the domain-joined devices (ncpa.cpl -> open the network adapter’s TCP/IPv4 settings and select Disable NetBIOS over TCPIP on the WINS tab);
  • Try resetting the network and TCP/IP stack settings on the Windows client device. On Windows 10+, you can use the Network Reset option in the Settings panel or use the command: netsh int ip reset

1 comment
6
Facebook Twitter Google + Pinterest
previous post
Couldn’t Verify Office 365 (Microsoft 365) Subscription
next post
How to Upgrade VM Hardware Version in VMware ESXi

Related Reading

Zabbix: How to Get Data from PowerShell Scripts

October 27, 2023

Tracking Printer Usage with Windows Event Viewer Logs

October 19, 2023

PowerShell: Configure Certificate-Based Authentication for Exchange Online (Azure)

October 15, 2023

How to Query and Change Teams User Presence...

October 8, 2023

How to Use Ansible to Manage Windows Machines

September 25, 2023

1 comment

Anonymous May 18, 2022 - 1:45 pm

Mir ist grade aufgefallen, dass es zu Beginn für 10-30 Sekunden schnell lädt (300-1000 mbit/s) und es danach dann runtergeht, auf paar kb/s, mit 10 Sekundenpausen zwischen den Pieks.

Der Kundenrechner ist in einer Domain und ich kann da nicht alles ausprobieren.

Set-SmbClientConfiguration -DirectoryCacheLifetime 0
Set-SmbClientConfiguration -FileInfoCacheLifetime 0
Set-SmbClientConfiguration -FileNotFoundCacheLifetime 0
Get-SmbClientConfiguration | Select *cache*
hat jedenfalls nichts geholfen (immer wieder witzig, dass man durch Abschalten eines Cache, der es ja eigentlich schneller machen soll, etwas schneller macht, anstatt langsamer … da hat jemand beim Delphi-Compiler abgeguckt )

[…] -FileNotFoundCacheLifetime 0 Get-SmbClientConfiguration| select *cache* von hat jedenfalls nichts geholfen (immer wieder witzig, dass man durch Abschalten eines Cache, der es […]https://www.delphipraxis.net/210601-start-von-share-ploetzlich-extrem-langsam-2.html#post1506023

Reply

Leave a Comment Cancel Reply

Categories

  • Active Directory
  • Group Policies
  • Exchange Server
  • Microsoft 365
  • Azure
  • Windows 11
  • Windows 10
  • Windows Server 2022
  • Windows Server 2019
  • Windows Server 2016
  • PowerShell
  • VMWare
  • Hyper-V
  • Linux
  • MS Office

Recent Posts

  • Zabbix: How to Get Data from PowerShell Scripts

    October 27, 2023
  • Tracking Printer Usage with Windows Event Viewer Logs

    October 19, 2023
  • PowerShell: Configure Certificate-Based Authentication for Exchange Online (Azure)

    October 15, 2023
  • Reset Root Password in VMware ESXi

    October 12, 2023
  • How to Query and Change Teams User Presence Status with PowerShell

    October 8, 2023
  • How to Increase Size of Disk Partition in Ubuntu

    October 5, 2023
  • How to Use Ansible to Manage Windows Machines

    September 25, 2023
  • Installing Language Pack in Windows 10/11 with PowerShell

    September 15, 2023
  • Configure Email Forwarding for Mailbox on Exchange Server/Microsoft 365

    September 14, 2023
  • How to View and Change BIOS (UEFI) Settings with PowerShell

    September 13, 2023

Follow us

  • Facebook
  • Twitter
  • Telegram
Popular Posts
  • Fix: Remote Desktop Licensing Mode is not Configured
  • Manage Windows Updates with PSWindowsUpdate PowerShell Module
  • Configuring Port Forwarding in Windows
  • Start Menu or Taskbar Search Not Working in Windows 10/11
  • How to Install Remote Server Administration Tools (RSAT) on Windows
  • How to Delete Old User Profiles in Windows
  • Get-ADUser: Find Active Directory User Info with PowerShell
Footer Logo

@2014 - 2023 - Windows OS Hub. All about operating systems for sysadmins


Back To Top