VB Script to set Java security level to medium
by, 28th October 2013 at 03:45 PM (13444 Views)
Long story short, Java started including an expiration timer on JRE releases. So many days after a release, regardless of update settings, a dialog will start popping up asking the user to update. This really isn't an issue, but with it JRE will stop running unsigned code. Many sites that my teaching staff have come to rely on have unsigned Java apps, and keeping over 500 frozen wireless laptops up to date every time a new version of JRE is released isn't really feasible. So enters VB script to get around the issue.
The code below is a sub from my logon script that deals with this issue. The setting the keeps Java from running said unsigned code is the security level and is stored in the deployment.propterties text file in each user's local profile. The default level is high and the line is not present in the config. Adding the line will force JRE into medium the next time it is launched. Since this is plucked out of my logon script you'll need a source for the username, but other than this it'll work as is for Vista/7. For 2k/XP you'll need to modify the path.
Code:Sub TempFixes5 Set objFSO = CreateObject("Scripting.FileSystemObject") Const ForReading = 1 Const ForWriting = 2 FoundIt = False strUserFilePath = "c:\Users\" & strUserName & "\AppData\LocalLow\Sun\Java\Deployment\deployment.properties" strSecurityMedium = "deployment.security.level=MEDIUM" 'Check to see if Java is installed, if not, then exit sub If objFSO.FileExists(strUserFilePath) Then 'Do Nothing Else Exit Sub End If 'Check to see if Java security is set to medium, if so, then exit sub FoundIt = (InStr(1,objFSO.OpenTextFile(strUserFilePath,1,true,-2).ReadAll,strSecurityMedium,1) <> 0) If FoundIt = True Then Exit Sub Else 'Do Nothing End If 'Open Java configuration files for reading Set objUserFile = objFSO.OpenTextFile(strUserFilePath, ForReading) 'Copy file contents into string strUserFile = objUserFile.ReadAll 'Add medium security line to config strNewUserFile = strUserFile & Chr(13) & strSecurityMedium 'Open Java configuration files for writing Set objUserFile = objFSO.OpenTextFile(strUserFilePath, ForWriting) 'Write the files objUserFile.WriteLine strNewUserFile 'Removes Java configuration file from memory objUserFile.Close 'House cleaning Set objFSO = Nothing End Sub
Total Trackbacks 0