Manage Learn to apply best practices and optimize your operations.

Updating the .ini preferences line with LotusScript

Here is some LotusScript code that will get the preferences line from the Notes.ini file and allow you to set one of the bit values. In the example below, I am setting the value to enable scheduled local agents. For a listing of the bit values that you can set, see this posting:

This code can be placed in a button, agent, etc., allowing you to update user preferences without touching their machine.
Dim session As New NotesSession
Dim currentPref As Long
Dim newPref As Long
Dim x As Long
Dim k As Long

Dim binPref As String
Dim a As String
Dim b As String
Dim number As String
Dim strPref As String

'get value from ini file and convert to string binary value
currentPref = session.GetEnvironmentValue( "Preferences", True )
binPref = Bin$(currentPref)

'We want to set digit 27 to "1". We have to work backwards (left to right) since this is a string.

a = Mid$(binPref, 1, 4)
b = Mid$(binPref, 6, 27)
number = a + "1" + b

'The following lines convert the binary number back to decimal
k = Len(number) ' will only work with 32 or fewer "bits"
For x = k To 1 Step -1 ' work backwards down string
    If Mid$(number, x, 1) = "1" Then
       If k - x > 30 Then ' bit 31 is the sign bit
          newPref = newPref Or -2147483648# ' avoid overflow error
          newPref = newPref + 2 ^ (k - x)
       End If
    End If
Next x

strPref = Trim(Cstr(newPref))

Call session.SetEnvironmentVar("Preferences", strPref, True)

Dig Deeper on Domino Resources - Part 5

  • Favorite iSeries cheat sheets

    Here you'll find a collection of valuable cheat sheets gathered from across the iSeries/ community. These cheat ...