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)
strPref = Trim(Cstr(newPref))
Call session.SetEnvironmentVar("Preferences", strPref, True)
This was first published in May 2001
Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.