'Button_to_Speed_up_Notes_8.x_(Windows): Sub Click(Source As Button) On Error Goto ErrorHandler '================================================== ' ' Button to speed up Lotus Notes 8.x ' ' Author: Marc Champoux ' Date: 2009 Aug 21 ' Version: 1.0 ' ' Description: ' This button will get the path of the notes client from the notes.ini. ' Once it has the path, it will try to look for some jvm.properties files ' in very very very specific directories. If we can file those ' jvm.properties file, the code will ask the user which memory ' settings to set in the jvm.properties file and make the mods. ' The code will keep a backup of the jvm.properties files btw :-) ' ' Usage: ' The easiest way to use this lss file is to create a new memo, ' then put the cursor in the body of the email. Once you are in the ' body of the email, click on Create -> Hotspot -> Button. In the ' button that appear, set the button type to LotusScript and then ' import this lss file. Once the code has appeared, you can click ' on the button and use it. Alternatively (if you are paranoid), you ' can save the email as a draft first if you think it will crash and ' burn. ' ' Revisions: ' Version 1.0 - Initial Version. ' ' Note #1: ' A bit long to code but it beats editing the jvm.properties files ' manually. ' ' Note #2: ' I check for the version that's installed but NOT for the type of ' client installed. This button is designed to work with the Notes ' Standard (the one with the Eclipse workspace) client. ' ' Note #3: ' Yes, I could have called a dll to get the amount of ram installed ' and then tweaked the code to select a number automatically in ' part 2 but I didn't want to tie this lotuscript code to a dll call. ' '================================================== '================================================== ' Declarations ... '================================================== Dim ButtonName As String ' The name of the button. Dim CurrUIWs As New NotesUIWorkspace ' The curent notes client session. Dim CurrSession As New NotesSession ' The current session. Dim CurrLNPath As String ' The current path of the notes client installation. Dim CurrLNPathFrameWork As String ' The path with the FrameWork folders we need. Dim CurrLNVersion As String ' The current version of the notes client. Dim DirectoriesScannedCounter As Integer ' The number of directories we found in the FrameWork folder. Dim DirectoriesScannedMatch As Integer ' The number of directories that matched the one we are looking for.. Dim DirectoryName As String ' The name of one of the directories in the FrameWork folder. Dim DirectoryToFind As String ' Part of the name of the folder to find. Dim FileFoundCounter As Integer ' The number of jvm.properties files we found. Dim FileFoundModifiedCounter As Integer ' The number of jvm.properties files we modified. Dim FileFoundLen As Long ' The lenght in bytes of the jvm.properties we found. Dim FileToFind As String ' The path name of the jvm.properties we need to find. Dim FileToCopyCounter As Integer ' The number of jvm-backup.properties files we created. Dim FileToCopyName As String ' The path name of the copy of the jvm.properties files we'll make. Dim FileToCopyLen As Long ' The Lenght in bytes of the jvm-backup.properties file we created. Dim FileBackupNumber As Integer ' The handle number for the jvm.properties file we'll back up. Dim FileBackupLine As String ' A line from the jvm-backup.properties file. Dim FileBackupLineToFind As String ' A line to find from the jvm-backup.properties file. Dim FileNewNumber As Integer ' The handle number for the jvm.properties file we'll create. Dim MemoryArray ( 11 ) As String ' The choices for memory that we'll prompt. Dim MemorySelected As String ' The amount of ram selected. Dim MemoryNewSetting As String ' The new line we'll put in the jvm.properties file. Dim Continue As Integer ' A variable to check if we continue or not at one point. Dim DateStamp As String ' The date stamp we'll put on the backup file. Dim TmpNewLine As String ' A new line for the strings and messages. '================================================== ' Initialize ... '================================================== ' Set the button name ... we'll use that later in the Print statements ButtonName = "Speed Up Notes" ' Print something ... Print ButtonName + " - Starting ..." ' Get the date stamp for the backup file ... DateStamp = Format ( Now , "YYYY-MM-DD-HH-MM-SS" ) ' Set the chars for a new line ... TmpNewLine = Chr$(10) + Chr$(13) + Chr$(10) + Chr$(13) '================================================== ' Part 1 - Get the Path and Version ... '================================================== ' Get the path ... CurrLNPath = CurrSession.GetEnvironmentString ( "NotesProgram" , True ) ' Make sure we have the path ... If Trim ( CurrLNPath ) = "" Then Messagebox "Unable to get the line ""NotesProgram="" from your Notes.ini. Please check to make sure this line is in your notes.ini." , 48 , "Error - INI Problem" Print ButtonName + " - Part 1 - Finished with Error ..." Exit Sub Else Print ButtonName + " - Part 1 - Lotus Notes is installed at this location: " + CurrLNPath End If ' Get the version ... CurrLNVersion = CurrSession.NotesVersion Print ButtonName + " - Part 1 - Lotus Notes is this version: " + CurrLNVersion ' Check for a " 8." in the version number ... If Instr ( 1 , CurrLNVersion , " 8." ) = 0 Then Messagebox "Sorry, this button is designed to work with Lotus Notes Version 8.x Standard. Please check to make sure that you are running the correct version and try again." , 48 , "Error - Version Problem" Print ButtonName + " - Part 1 - Finished with Error ..." Exit Sub Else Print ButtonName + " - Part 1 - Lotus Notes is running one of the supported versions for this button" End If '================================================== ' Part 2 - Get the system memory and ask the person what does ' he/she wants to set the jvm.properties settting to. '================================================== ' Set the choices for memory ... (yes,I could have done a loop if I ' wanted to but I decided to just dim the values here without any ' fancy steps ... MemoryArray ( 0 ) = "256" MemoryArray ( 1 ) = "512" MemoryArray ( 2 ) = "768" MemoryArray ( 3 ) = "1024" MemoryArray ( 4 ) = "1280" MemoryArray ( 5 ) = "1536" MemoryArray ( 6 ) = "1792" MemoryArray ( 7 ) = "2048" MemoryArray ( 8 ) = "2304" MemoryArray ( 9 ) = "2560" MemoryArray ( 10 ) = "2816" MemoryArray ( 11 ) = "3072" ' Let the user know about the next step ... Messagebox "In the next screen, you will be prompted to select a value which is roughly 1/3 of the amount of system memory (RAM) installed in your computer." + TmpNewLine + "If you don't know how much memory (RAM) is installed in your computer, click on Start -> Run -> type ""WINVER"" (without the quotes) and click on OK. The amount of RAM is written at the bottom of the screen that will appear." + TmpNewLine + "Selecting a value higher than 1/3 of your RAM might cause performance issues with other applications. So if you notice changes in the behavior of other applications afterwards, simply re-run this tool and select a lower value." , 64 , "FYI - RAM Selection Screen" ' Prompt the user to select 1/3 of his RAM ... Print ButtonName + " - Part 2 - Prompting for the new memory setting ..." MemorySelected = CurrUIWs.Prompt ( 4 , "Select 1/3 of your System Memory (RAM)" , "Please select from the list below the number which roughly equates to 1/3 of the memory installed in your computer." , "256" , MemoryArray ) ' Verify that the person selected something ... If MemorySelected = "" Then ' Tell the person this isn't good ... Messagebox "You did not select any value. Please try again." , 48 , "No value selected" Print ButtonName + " - Part 2 - Finished with Error ..." Exit Sub Else ' Since we are paranoid ... let's ask the person if he/she is sure if his/her selection ... Print ButtonName + " - Part 2 - Verifying new memory setting selection..." Continue = Messagebox ( "You have selected that """ + MemorySelected + """ is roughly 1/3 of your installed system memory (RAM). Do you want to continue?" , 36 , "Continue?" ) ' Check the choice ... If Continue = 7 Then ' Ok, your wish is my command so get out ... Print ButtonName + " - Cancelled by user ..." Exit Sub End If End If ' End of the "If MemorySelected = "" Then" ' Set the new line we'll put back in the jvm.properties file (if we find it!) FileBackupLineToFind = "vmarg.Xmx=-Xmx" MemoryNewSetting = FileBackupLineToFind + MemorySelected + "m" '================================================== ' Part 3 - Look for the directories in the FrameWork folderr '================================================== ' Set the path that we need to look in ... CurrLNPathFrameWork = CurrLNPath + "framework\rcp\eclipse\plugins\" ' Set the name of the directory to find (actually it's not the complete name but it's normal) DirectoryToFind = "com.ibm.rcp.j2se.win32.x86_" ' Set the counters ... DirectoriesScannedCounter = 0 DirectoriesScannedMatch = 0 FileFoundCounter = 0 FileToCopyCounter = 0 FileFoundModifiedCounter = 0 ' Scan for folders in this path ... Print ButtonName + " - Part 3 - Scanning for folders in " + CurrLNPathFrameWork DirectoryName = Dir$ ( CurrLNPathFrameWork , 16 ) ' Check to see if we found at least 1 directory ... Do While DirectoryName <> "" ' Increase the counter for the number of directories found ... DirectoriesScannedCounter = DirectoriesScannedCounter + 1 ' Now try to find if it matches the name of the folder we need ... ' Note: yes, I used another lcase on the Directory to find ... just in case someone later modifies my code ' and dosen't put the folder name in lowercase ... If Instr ( 1 , Lcase ( DirectoryName ) , Lcase ( DirectoryToFind) ) > 0 Then ' Ok, we found one of the directories ... increase the counter ... Print ButtonName + " - Part 3 - Found Folder : " + DirectoryName ' Check to see if the file jvm.properties exist in the folder that matched ... FileToFind = CurrLNPathFrameWork + DirectoryName + "\jvm.properties" ' Now issue a FileLen command to see if the jvm.properties file exist and how big it is. ' The reason why I'm not issuing another dir command is that it would loose the point to the directory dir commands that ' I'm looping in right now ... FileFoundLen = Filelen ( FileToFind ) ' Check if the file was found ... If FileFoundLen > 0 Then ' Increase the counter for the number of jvm.properties files that were found. FileFoundCounter = FileFoundCounter + 1 ' Print something ... Print ButtonName + " - Part 3 - Found a jvm.properties file in the following directory: " + DirectoryName ' Now, set the new name for the file (because we want to make a copy) FileToCopyName = CurrLNPathFrameWork + DirectoryName + "\jvm-backup-" + DateStamp + ".properties" ' Now make the copy ... Filecopy FileToFind , FileToCopyName ' Be paranoid ... make sure that the file copy worked ... FileToCopyLen = Filelen ( FileToCopyName ) ' Only proceed IF the file copy worked ... If FileToCopyLen > 0 Then ' Ok, we were able to make a backup so increase the counter ... FileToCopyCounter = FileToCopyCounter + 1 ' Now, open the jvm-backed.properties file in read mode ... FileBackupNumber = Freefile () Open FileToCopyName For Input Access Read As FileBackupNumber ' Open the jvm.properties file in write mode ... basically overwritting what's in there already. FileNewNumber = Freefile () Open FileToFind For Output As FileNewNumber ' Loop in the backup file ... Do While Not Eof ( FileBackupNumber ) ' Read 1 line from the jvm-backup.properties file ... Line Input #FileBackupNumber, FileBackupLine ' Check if that line is the one we need to modify ... If Instr ( 1 , Lcase ( FileBackupLine ) , Lcase ( FileBackupLineToFind ) ) = 1 Then ' Ok, we are about to modify a jvm.properties file so ... increase the counter ... FileFoundModifiedCounter = FileFoundModifiedCounter + 1 ' Ok, replace the line with the user selection ... Print #FileNewNumber, MemoryNewSetting Else ' It's not the line we need to modify so simply put back what we've read ... Print #FileNewNumber, FileBackupLine End If Loop ' Close the new and backup file ... Close FileBackupNumber Close FileNewNumber Else ' Oups, we weren't able to make a copy ... Print ButtonName + " - Part 3 - Unable to make a backup of the jvm.properties file found in the following directory: " + DirectoryName End If ' End of the "If FileToCopyLen > 0 Then" End If ' End of the "If FileFoundLen > 0 Then" End If ' End of the "If Instr ( 1 , Lcase ( DirectoryName ) , "" ) > 0 Then" ' Get the next directory ... DirectoryName = Dir$() Loop '================================================== ' Part 4 - Alrighty ... check the results ... '================================================== ' Alrighty ... if we are here it's because the looping and modifying is done ... so check the results. ' Check if 0 jvm.properties files were found ... If FileFoundCounter = 0 Then ' Oups, no jvm.properties files were found ... Messagebox "There were no jvm.properties found in the directories that start with """ + DirectoryToFind + """ in the path """ + CurrLNPathFrameWork + """." + TmpNewLine + "Please verify that you are running Lotus Notes 8.x Standard and that your ntoes.ini contains the line ""NotesProgram"" and that it points to the correct place." , 48 , "No jvm.properties file modified" End If ' Check if jvm.properties files were found If FileFoundCounter > 0 Then ' Check if 0 were modified ... If FileFoundModifiedCounter = 0 Then ' Well ... something went wrong ... jvm.properties files were found ... but none were modified ... If FileFoundCounter = 1 Then Messagebox "1 jvm.properties file was found in the directory that starts with """ + DirectoryToFind + """ in the path """ + CurrLNPathFrameWork + """ BUT it was not modified." + TmpNewLine + "Please verify that it contains a line that starts with """ + FileBackupLineToFind + """ and try again." , 48 , "1 jvm.properties file found but not modified" Else Messagebox Cstr ( FileFoundCounter ) + " jvm.properties files were found in the directories that starts with """ + DirectoryToFind + """ in the path """ + CurrLNPathFrameWork + """ BUT they were not modified." + TmpNewLine + "Please verify that they contains a line that starts with """ + FileBackupLineToFind + """ and try again." , 48 , "1 jvm.properties file found but not modified" End If Else ' Check if the number of files modified is lower than the number of files found ... If FileFoundModifiedCounter < FileFoundCounter Then ' Well ... something went wrong ... jvm.properties file(s) were found ... but some weren't modified ... If FileFoundCounter = 1 Then Messagebox "1 jvm.properties file was found in the directory that starts with """ + DirectoryToFind + """ in the path """ + CurrLNPathFrameWork + """ BUT it was not modified." + TmpNewLine + "Please verify that it contains a line that starts with """ + FileBackupLineToFind + """ and try again." , 48 , "1 jvm.properties file found but not modified" Else If FileFoundModifiedCounter = 1 Then Messagebox Cstr ( FileFoundCounter ) + " jvm.properties files were found in the directories that starts with """ + DirectoryToFind + """ in the path """ + CurrLNPathFrameWork + """ BUT only 1 was modified." + TmpNewLine + "Please verify that each jvm.properties file in the path specified contain a line that starts with """ + FileBackupLineToFind + """ and try again." , 48 , "jvm.properties files found but only 1 modified" Else Messagebox Cstr ( FileFoundCounter ) + " jvm.properties files were found in the directories that starts with """ + DirectoryToFind + """ in the path """ + CurrLNPathFrameWork + """ BUT only " + Cstr ( FileFoundModifiedCounter ) + " files were modified." + TmpNewLine + "Please verify that each jvm.properties file in the path specified contain a line that starts with """ + FileBackupLineToFind + """ and try again." , 48 , "jvm.properties files found but only some were modified" End If End If Else ' Ok, the numbers match! Tell the person ... If FileFoundCounter = 1 Then Messagebox "The jvm.properties file that was found on your hard drive was modified. Please close and re-open Lotus Notes to see the difference." , 64 , "1 jvm.properties file modified" Else Messagebox Cstr ( FileFoundCounter ) + " jvm.properties files were found on your hard drive and modified. Please close and re-open Lotus Notes to see the difference." , 64 , Cstr ( FileFoundCounter ) + " jvm.properties files modified" End If End If ' End of the "If FileFoundModifiedCounter < FileFoundCounter Then" End If ' End of the "If FileFoundModifiedCounter = 0 Then" End If ' End of the "If FileFoundCounter > 0 Then" '================================================== ' Part 5 - One last mod ... '================================================== ' Messagebox this last tip ... Messagebox "Another tip to speed up your Lotus Notes client is to disable the setting ""Launch Lotus Symphony in the Backround when the Operating System Starts"" in your preferences." + TmpNewLine + "This setting can be found by clicking on File -> Preferences and then by clicking on the ""Lotus Symphony"" category (if you have installed Lotus Symphony)." , 64 , "One last tip ..." '================================================== ' Ok, we're done ... '================================================== ' Print something ... Print ButtonName + " - Finished ..." ' Get out instead of going into the errorhandler Exit Sub ErrorHandler: ' Check if this is a "Path Not Found" error .. If Err = 76 Then Messagebox "Sorry but the path """ + CurrLNPathFrameWork + """ does not exist on your computer. You are probably using the Notes 8.x Basic client and this code only works with the Lotus Notes 8.x Standard client. Please verify that the path exists and that you are using the correct version and try again." , 48 , "Error - Path Not Found" Print ButtonName + " - Finished with Error ..." Exit Sub Else ' Now trap the error "File Not Found" that can happen when issuing the FileLen command to find the jvm.properties file If Err = 53 Then ' In this particular case, we just want to resume next ... Resume Next Else ' Trap other errors ... Messagebox "Error" & Str(Err) & ": " & Error$ Print ButtonName + " - Finished with Error ..." Exit Sub End If End If End Sub