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

Answer Summary:
Cancel
0 Comments   [ + ] Show Comments

Comments

Please log in to comment

Answers

0
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:

http://www.itninja.com/blog/view/how-to-hide-running-a-batch-file-from-a-kscript-with-version-5-5
Answered 01/14/2015 by: SMal.tmcc
Red Belt

  • I created the script
    vbs.
    CreateObject("Wscript.Shell").Run"Javacachedel",0,True

    bat
    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.
    • I fogot I added /s/q and still does not work through kace.
Please log in to comment
0
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

Directory:
$(KACE_DEPENDENCY_DIR)
File: (yes the double quotes are necessary for this to work)
"c:\windows\system32\wscript.exe"
Parameters:
script.vbs



Answered 01/14/2015 by: SMal.tmcc
Red Belt

  • make sure this is a online script and you select "windows run as" = logged-in user
  • 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.
    • Thank you so much it works. I guess I forgot the .bat in vbs and run as logon user.
      • 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
      • 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.
Please log in to comment
Answer this question or Comment on this question for clarity