Deleting Java Cache

Hello All,

 I'm looking for a script to delete Java cache files. I have to remote into user's pc to delete the cache once in a while and would be nice to delete it through script.


Thank you

0 Comments   [ + ] Show comments

Answers (2)

Answer Summary:
Posted by: SMal.tmcc 6 years ago
Red Belt
you would need to run the script as logged-in user since that is in the profile area. 

del %HOMEPATH%\appdata\LocalLow\Sun\Java\Deployment\cache\6.0\*.* /s /q

You can create a batch file and run it invisible this way:


  • I created the script

    del %HOMEPATH%\appdata\LocalLow\Sun\Java\Deployment\cache\6.0\*.*
    kscript file: "c:\windows\system32\wscript.exe"
    Parameters: javacachedelete.vbs.
    I even run it on the test PC and the only thing works is the batch file. VBS does nothing. - Kdebiasse 6 years ago
    • I fogot I added /s/q and still does not work through kace. - Kdebiasse 6 years ago
Posted by: SMal.tmcc 6 years ago
Red Belt
ok your vbs code needs to be
CreateObject("Wscript.Shell").Run "Javacachedel.bat",0,True
the Javaschedel.bat needs to be
del %HOMEPATH%\appdata\LocalLow\Sun\Java\Deployment\cache\6.0\*.* /s /q
create a script and add both those as dependencies.
now when you create your launch a program

File: (yes the double quotes are necessary for this to work)

  • make sure this is a online script and you select "windows run as" = logged-in user - SMal.tmcc 6 years ago
  • the reason I have my launch that way is the kbot file structure is generated by the id number of the script so that is a not a fixed constant. To get around that I use the variable $(KACE_DEPENDENCY_DIR) as the launch directory of the program, that way the kbox knows the id and can go there to start the call. I then call the program with quotes to trick the engine into calling an executable in another location, otherwise it will try to launch wscript from the $(KACE_DEPENDENCY_DIR) and fail. and since cmd interpreter is in the $(KACE_DEPENDENCY_DIR) when it starts the "wscript.exe script.vbs" it finds the parameter in that directory and runs the vbs file. - SMal.tmcc 6 years ago
    • Thank you so much it works. I guess I forgot the .bat in vbs and run as logon user. - Kdebiasse 6 years ago
      • thats why I like to post it in pictures or code, it helps you compare to find the difference, the scripts do not forgive code errors - SMal.tmcc 6 years ago
      • always remember any script that has a user level environment variable like %homepath%, %APPDATA%, %USERPROFILE%, etc has to be run as user, the system has no clue what those stand for. - SMal.tmcc 6 years ago

Don't be a Stranger!

Sign up today to participate, stay informed, earn points and establish a reputation for yourself!

Sign up! or login

View more:


This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ