Scripting: Clean Java temporary install files from User Profiles – Win 7 & XP

So I had an issue awhile back that need to be rectified and the fix was to clean out temporary install files from the Sun/Java folder in User profiles. This had to be done on about 700 machines, so I created this little script that cleans out these files and pushed it out to via AD. I hope you enjoy…..

Win 7 – Clean Java Temp Files

CD C:\

CLS

ECHO


REM *** This DELETES temporary install files from the
REM *** SUN/JAVA folder in User Profiles.
REM *** Run this if you get a Pop-Up warning about your
REM *** User Profile being too large.
REM *** Click the corner [X] to exit without running.
REM *** Otherwise press the [Spacebar] to continue.

PAUSE

DEL "%USERPROFILE%\AppData\LocalLow\Sun\Java\*.*" /S /F /Q

RD "%USERPROFILE%\AppData\LocalLow\Sun\Java\" /S /Q

DEL "%USERPROFILE%\AppData\Local\Temp\*.*" /S /F /Q

RD "%USERPROFILE%\AppData\Local\Temp\" /S /Q

CLS

REM *** Folders are cleaned!

PAUSE

EXIT

Win XP – Clean Java Temp Files


CD C:\

CLS

ECHO

REM *** This script is for Windows XP only it will NOT work on Vista or 7
REM *** This DELETES temporary install files from the
REM *** SUN\JAVA and Local Settings\Temp folders in User Profiles.
REM *** Run this if you get a Pop-Up warning about your
REM *** User Profile being too large.
REM *** Click the corner [X] to exit without running.
REM *** Otherwise press the [Spacebar] to continue.

PAUSE

DEL "%SYSTEMDRIVE%\Documents and Settings\%USERNAME%\Application Data\Sun\Java\*.*" /S /F /Q

RD "%SYSTEMDRIVE%\Documents and Settings\%USERNAME%\Application Data\Sun\Java\" /S /Q

DEL "%SYSTEMDRIVE%\Documents and Settings\%USERNAME%\Local Settings\Temp\*.*" /S /F /Q

RMDIR "%SYSTEMDRIVE%\Documents and Settings\%USERNAME%\Local Settings\Temp\" /S /Q

CLS

REM *** Folders are cleaned!

PAUSE

EXIT

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s