title: How to verify and disable SMB oplocks and caching in FoxPro application startup
body: <p>I read that using SMB opportunistics locking and file caching causes data corruption in FoxPro.</p>
  
  <p>How to verify that those are disabled and disable them in needed at application startup with minimal user action required?</p>
  
  <p>Should VFP application check registry keys like</p>
  
  <pre>
  HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\lanmanserver\parameters\Smb1
  >HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\lanmanserver\parameters\Smb2
  >HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\lanmanserver\parameters\EnableOplocks
  >HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\MRXSmb\Parameters\OplocksDisabled
  >HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanWorkstation\Parameters\UseOpportunisticLocking
  >HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanWorkstation\parameters\DirectoryCacheLifetime
  >HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanWorkstation\parameters\FileInfoCacheLifetime
  >HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanWorkstation\parameters\FileNotFoundCacheLifetime
  </pre>
  
  <p>or parse powershell Set-SmbClientConfiguration  or msinfo output or is there better way ?</p>
  
  <p>How to set them in application startup ?
  Should application require registry access and wrote values to registry or invoke powershell like</p>
  
  <pre>
  Set-SmbClientConfiguration -EnableMultiChannel $false
  Set-SmbClientConfiguration -OplocksDisabled $True
  Set-SmbClientConfiguration -UseOpportunisticLocking $False
  </pre>
  
  <p>or powershell  script like</p>
  
  <pre>
  `$Name1 = “DirectoryCacheLifetime”
  $Name2 = “FileInfoCacheLifetime”
  $Name3 = “FileNotFoundCacheLifetime”
  $value = “0”
  New-ItemProperty -Path $registryPath -Name $name1 -Value $value -PropertyType DWORD -Force | Out-Null
  New-ItemProperty -Path $registryPath -Name $name2 -Value $value -PropertyType DWORD -Force | Out-Null
  New-ItemProperty -Path $registryPath -Name $name3 -Value $value -PropertyType DWORD -Force | Out-Null`
  
  </pre>
  
  <p>Using Visual FoxPro 9 , mostly in Windows 10</p>
  
  <p>Answer in </p>
  
  <p><a href="https://stackoverflow.com/questions/50418733/vfp-networking-issues-with-windows-10-1803">VFP networking issues with Windows 10 1803</a></p>
  
  <p>described how to do this manually but I'm looking for automatic solution which requires minimal user interaction.</p>