Rewrite Memory size for JNLP Web Clients

Well today I ran into a weird issue where a JNLP file wouldn’t launch the JVM. Through some troubleshooting, I discovered it was because more virtual memory than could be assigned was being assigned. I wrote this little script that goes and gets the latest ws file, searches for 1024m and replaces with 768m then runs the file.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
Const ForReading = 1
Const ForWriting = 2
 
Dim fso, folder, files, NewsFile,sFolder, dDateModified, jnlpFile
dDateModified = CDate("1/1/2000")
Set fso = CreateObject("Scripting.FileSystemObject")
Set sFolder = fso.GetSpecialFolder(2)
 
If sFolder = "" Then
    	Wscript.Echo "No Temp Folder Found"    
	Wscript.Quit
End If
 
Set folder = fso.GetFolder(sFolder)
Set files = folder.Files 
 
For each fil In files
    if (InStr(fil.Name,"javaws") > 0 and fil.DateLastModified > dDateModified) then
        dDateModified = fil.DateLastModified        
	jnlpFile = fil.Name
    end if
 
Next
 
if jnlpFile <> "" then
	Set objFile = fso.OpenTextFile(sFolder.Path & "\" & jnlpFile, ForReading)
    	strText = objFile.ReadAll    
	objFile.Close
    	strNewText = Replace(strText, "1024m", "768m")
    	Set objFile = fso.OpenTextFile(sFolder.Path & "\" & jnlpFile, ForWriting)
    	objFile.WriteLine strNewText    
	objFile.Close
    	Set WshShell = WScript.CreateObject("WScript.Shell")
    	WshShell.Run("javaws " & """" & sFolder.Path & "\" & jnlpFile & """")    
	Set oShell = Nothing
end if

Leave a Comment