Sign in to follow this  
Followers 0
rudi

script to turn off OpLocking (XP, Win7-32, 2008-R2 tested)

1 post in this topic

Hi.

Two weeks ago or so I had to track down odd issues with a medical software, that's dependant on Borland BDE databases. It worked fine from XP clients against a Win2003 (R1) server.

That office moved, now running on Win7-32bit Clients against a Win2008-R2 server. The symtoms were pointing in the direction of oplocks issues. There is a integrated "Oplocking checker" in that software, so I trusted in it's results, stating OK.

Asking Google showed, that with Win7 / 2008-R2 some new Reg Values need to be modified, these weren't checked by that software, so I wrote this Q&D script. It's purpose is to check (and disable) oplocks. I simply used the same script server and client side:

; Oplocks komplett ausschalten

#include <GUIConstantsEx.au3>
#RequireAdmin
$Title = "OpLock Checker"

Dim $aOpDis[8][4] = [[7], _
        ["HKLM\System\CurrentControlSet\Services\MRXSmb\Parameters", "OplocksDisabled", "REG_DWORD", 1], _
        ["HKLM\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters", "EnableOpLocks", "REG_DWORD", 0], _
        ["HKLM\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters", "EnableOpLockForceClose", "REG_DWORD", 1], _
        ["HKLM\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters", "CachedOpenLimit", "REG_DWORD", 1], _
        ["HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanWorkstation\Parameter", "EnableOpLocks", "REG_DWORD", 0], _
        ["HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanWorkstation\Parameter", "EnableOpLockForceClose", "REG_DWORD", 1], _
        ["HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanWorkstation\Parameter", "CachedOpenLimit", "REG_DWORD", 1]]


$w = 1000
$h = 250
$LTxt = "Prüfe Einstellung für Oplocks:" & @CRLF & @CRLF ; checking Oplock settings

GUICreate($Title, $w, $h)
$Label = GUICtrlCreateLabel($LTxt, 10, 10, $w - 10, $h - 10)
GUISetState()


$OK = True
$Anders = False
For $i = 1 To $aOpDis[0][0]
    $Key = $aOpDis[$i][0]
    $Val = $aOpDis[$i][1]
    $Type = $aOpDis[$i][2]
    $Soll = $aOpDis[$i][3]
    $Current = RegRead($Key, $Val)
    If @error <> 0 Then
        $LTxt &= $Key & ", " & $Val & ": Wert noch nicht angelegt " ; value not existing yet
        _RegWrite()
    Else
        If $Current = $Soll Then
            $LTxt &= $Key & ", " & $Val & "=" & $Current & ": Wert *IST* schon korrekt gesetzt." & @CRLF ; value is correct *ALREADY*
        Else
            $LTxt &= $Key & ", " & $Val & "=" & $Current & ": Wert vorhanden, pass nicht! " ; value present, but incorrect
            _RegWrite()
        EndIf
    EndIf
Next

$LTxt &= @CRLF

If $OK Then ; keine Fehler aufgetreten
    If $Anders = False Then
        $LTxt &= "Oplocking *WAR* schon komplett abgeschaltet." & @CRLF & "Der Rechner muss *NICHT* neu gestartet werden."; oplocking *WAS* disabled, no reboot required.
    Else
        $LTxt &= "Oplocking wurde deaktiviert." & @CRLF & "!!!! Der Rechner muss neu gestartet werden, damit die Änderungen vollständig wirksam werden!!!!"; oplocking is disabled *NOW*. Reboot required.
    EndIf
Else ; OK = false, es *SIND* Fehler aufgetreten
    If $Anders = False Then
        $LTxt &= "Oplocking ist *NICHT* vollständig abgeschaltet." & @CRLF & "Bitte oben Ausgaben auf Fehler Prüfen!!" ; error: Oplocking couldn't be (fully) disabled.
    Else
        $LTxt &= "Unklarer Zustand:" & @CRLF & "Es wurden keine Änderungen als erforderlich erkannt, trotzdem sind Schreifehler aufgetreten??" ; undefined condition: nothing had to be changed, nevertheless write errors occured.
    EndIf
EndIf

$LTxt &= @crlf & @crlf & "Zum Schliessen des Fensters ""Esc"" drücken!" ; press ESC to close this windows

L_UP()


While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
    EndSelect
    Sleep(100)
WEnd




Func _RegWrite()
    $Anders = True ; Änderung erforderlich.
    If RegWrite($Key, $Val, $Type, $Soll) Then
        $LTxt &= "- korrigiert (OK)" & @CRLF
        L_UP()
    Else
        $OK = False
        $LTxt &= " - FEHLER! (konnte Wert nicht setzten!!!)" & @CRLF ; Error: couldn't write value.
        L_UP()
    EndIf
EndFunc   ;==>_RegWrite


Func L_UP()
    GUICtrlSetData($Label, $LTxt)
EndFunc   ;==>L_UP

I think I've googled successfully all the registry values in question. If somebody knows one, that I've missed, please add it. :>

Feel free to beautify GUI and script, if you want to :unsure:, I just had to use it exactly once per Computer in that LAN...

Regards, Rudi.


Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Share this post


Link to post
Share on other sites



Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0