'---------------------------------------------------------------------------------------------------------------------------- 'Script Name : disableJavaCacheAndDeleteCache.vbs 'Description : This script searches for the deployment.properties file and checks if local caching is turned on. If it is, ' the script will disable local caching and delete the cache folder. '---------------------------------------------------------------------------------------------------------------------------- 'Initialization Section '---------------------------------------------------------------------------------------------------------------------------- On Error goto 0 Const ForReading = 1, ForWriting = 2, ForAppending = 8, USER_PROFILE = &H1a& Set objFSO = CreateObject("Scripting.FileSystemObject") '---------------------------------------------------------------------------------------------------------------------------- 'Set file and folder locations '---------------------------------------------------------------------------------------------------------------------------- Set objShell = CreateObject("Shell.Application") Set objFolder = objShell.Namespace(USER_PROFILE) Set objFolderItem = objFolder.Self Dim deployementLocation Dim fileLocation deployementLocation = objFolderItem.Path & "\Sun\Java\Deployment\" fileLocation = deployementLocation & "deployment.properties" cacheLocation = deployementLocation & "cache\6.0" '---------------------------------------------------------------------------------------------------------------------------- 'Check if the file exists '---------------------------------------------------------------------------------------------------------------------------- If objFSO.FileExists(fileLocation) then '---------------------------------------------------------------------------------------------------------------------------- 'Open the file for reading '---------------------------------------------------------------------------------------------------------------------------- Set listFile = objFSO.OpenTextFile(fileLocation, ForReading, False) Dim disabled '---------------------------------------------------------------------------------------------------------------------------- 'Read each line and search for "deployment.cache.enabled=false". If it finds it, set the variable disabled to disabled and 'exit the for loop. If not, then set the disabled variable to not disabled. '---------------------------------------------------------------------------------------------------------------------------- do while not listFile.AtEndOfStream if listFile.ReadLine() = "deployment.cache.enabled=false" then disabled = "disabled" exit do else disabled = "not disabled" end if loop listFile.close '---------------------------------------------------------------------------------------------------------------------------- 'Check it the setting is disabled '---------------------------------------------------------------------------------------------------------------------------- if disabled = "not disabled" then '---------------------------------------------------------------------------------------------------------------------------- 'Open the file for appending and append the line to disable local cache '---------------------------------------------------------------------------------------------------------------------------- Set appendFile = objFSO.OpenTextFile(fileLocation, ForAppending, False) appendFile.WriteLine("deployment.cache.enabled=false") appendFile.close '---------------------------------------------------------------------------------------------------------------------------- 'Check if the cache folder exists and delete it if it does '---------------------------------------------------------------------------------------------------------------------------- If objFSO.FolderExists(cacheLocation) then objFSO.DeleteFolder cacheLocation, True end if end if end if