A VBS script to add an extension/addin to the Lotus Notes ini file.
The script will either append to the “Extmgr_Addins” line if it is already there or it will create the line first.
Simple change the variables “notes_ini_path” and “extension_to_add”
If your ini path varies you may want to pull the path from the registry, this article may be a good starting point but feel free to comment.
Set objFSO=Createobject("Scripting.FileSystemObject")
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8
notes_ini_path = "H:\notes\data\notes.ini"
extension_to_add = "psns.dll"
If objFSO.FileExists(notes_ini_path) then
Set notes_ini_file = objFSO.OpenTextFile(notes_ini_path, ForReading)
Do While notes_ini_file.AtEndOfStream <> True
current_line = notes_ini_file.ReadLine
if InStr(1,current_line, "Extmgr_Addins",1) Then
'Extmgr_Addins Line found in the ini
Extmgr_Addins_Found = True
if InStr(1,current_line, extension_to_add,1) = 0 then
'Extention not in the Extmgr_Addins list so add it
EXTENSION_NOT_FOUND = True
new_notes_ini_file = new_notes_ini_file & current_line & "," & extension_to_add & chr(13) & chr(10)
End if
Else
new_notes_ini_file = new_notes_ini_file & current_line & chr(13) & chr(10)
End if
Loop
notes_ini_file.Close
'Extmgr_Addins Line not found in the ini so creae it and add the extension
if Extmgr_Addins_Found = False Then
new_notes_ini_file = new_notes_ini_file & "Extmgr_Addins=" & extension_to_add & chr(13) & chr(10)
End if
'Write the new ini file if needed
if Extmgr_Addins_Found = False or EXTENSION_NOT_FOUND = True Then
Set new_notes_ini_output = objFSO.OpenTextFile(notes_ini_path, ForWriting)
new_notes_ini_output.Write(new_notes_ini_file)
new_notes_ini_output.Close
End if
End if
I found a bug with this script where the extension was repeatability added to the notes ini, I have now updated the script and the attached file
The line if not InStr(1,current_line, extension_to_add,1) then was changed to if InStr(1,current_line, extension_to_add,1) = 0 then