Tip

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:

http://searchdomino.techtarget.com/tip/1,289483,sid4_gci489680,00.html

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
       Else
          newPref = newPref + 2 ^ (k - x)
       End If
    End If
Next x

strPref = Trim(Cstr(newPref))

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

This was first published in May 2001

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: 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.