back to Deljunk
back to Computer stuff
home

Copy and paste the following (but don't include the "last updated" line!) into C:\bat\deljunk.bat

@echo off

REM "if exist *.*", or its converse, detects hidden files.

echo Note: Remember to watch the echoed directory when reminded "All files in
echo directory will be deleted!", especially if running this utility after making
echo changes to this script or to the directory structure of the computer.
REM (Suggest 80 column editing guide here - use dots and vertical lines and copy and paste)
REM As the programmer, always check for the directory before going to it
REM (eg "if not exist winzip.log goto CW32"),
REM and always put a "cd" by itself before any delete command, for the benefit of the user (you!).
REM As the user, train yourself to watch the echoed directory before approving any deletes.

echo Directories will be echoed where junk found
c:\windows\command\choice /C:ync /N "Have you quit all running programs -- OK to start? (y/n/c)>"
if errorlevel 3 goto END
if errorlevel 2 goto END

c:

echo Searching for junk to delete... (directories echoed where junk found)
echo.

cd\
if not exist winzip.log goto DWINZIP
echo c:\winzip.log found; deleting...
del winzip.log
if not exist winzip.log echo c:\winzip.log has been successfully deleted.
if exist winzip.log echo c:\winzip.log Was not successfully deleted!
echo.

:DWINZIP
if not exist d:\winzip.log goto SCNDLOG
echo d:\winzip.log found; deleting...
del d:\winzip.log
if not exist d:\winzip.log echo d:\winzip.log has been successfully deleted.
if exist d:\winzip.log echo d:\winzip.log Was not successfully deleted!
echo.

:SCNDLOG
if not exist scandisk.log goto DSCNDL
c:\windows\command\choice /C:ync /N "C:\Scandisk Log exists. Delete? (y/n/c)>"
if errorlevel 3 goto FUP
if errorlevel 2 goto DSCNDL
del scandisk.log
if not exist scandisk.log echo C:\Scandisk.log has been successfully deleted.
if exist scandisk.log echo C:\Scandisk.log Was not successfully deleted!
echo.

:DSCNDL
if not exist d:\scandisk.log goto CW32
c:\windows\command\choice /C:ync /N "D:\Scandisk Log exists. Delete? (y/n/c)>"
if errorlevel 3 goto FUP
if errorlevel 2 goto CW32
del d:\scandisk.log
if not exist d:\scandisk.log echo D:\Scandisk.log has been successfully deleted.
if exist d:\scandisk.log echo D:\Scandisk.log Was not successfully deleted!
echo.

:CW32
if not exist c:\cw32\nul goto JUNO
cd\cw32
if not exist cwright.bak goto JUNO
cd
del cwright.bak

:JUNO
if not exist c:\Progra~1\Juno\nul goto SECT2
if not exist c:\Progra~1\Juno\Ads\nul goto CHKJLOG
cd\Progra~1\Juno\Ads
if not exist *.* goto CHKJLOG
cd
echo Files found in Juno\Ads;
cd..
c:\windows\command\deltree /Y Ads
md Ads
echo ...Juno Ads directory recreated;

:CHKJLOG
echo.
if not exist c:\Progra~1\Juno\bin\nul goto SECT2
cd\Progra~1\Juno\bin
if not exist Client.lo? if not exist Eventlog.lo? goto SECT2
cd
if exist Client.lo? echo Deleting Juno Client Logs...
if not exist Client.lo? echo Juno Client Logs not found.
if exist Client.lo? del Client.lo?
if exist Eventlog.lo? echo Deleting Juno Event Logs...
if not exist Eventlog.lo? echo Juno Event Logs not found.
if exist Eventlog.lo? del Eventlog.lo?
echo.

:SECT2

REM Wipe .jpi cache in c:\Windows -- new section after installing Netscape ver 7.02 -- I think that was the culprit
if not exist c:\WINDOWS\JPI_CA~1\nul goto DONEJC
if not exist c:\WINDOWS\JPI_CA~1\file\1.0\nul goto CHKJCJ
cd\WINDOWS\JPI_CA~1\file\1.0
if not exist *.* goto CHKJCJ
c:\Windows\Command\Attrib -h *.*
c:\Windows\Command\Attrib -r *.*
cd
del .
echo.

:CHKJCJ
if not exist c:\WINDOWS\JPI_CA~1\jar\1.0\nul goto DONEJC
cd\WINDOWS\JPI_CA~1\jar\1.0
if not exist *.* goto DONEJC
c:\Windows\Command\Attrib -h *.*
c:\Windows\Command\Attrib -r *.*
cd
del .
echo.

:DONEJC

REM This is the Netscape ver 7.02 block
:V7NSC
if not exist c:\Windows\APPLIC~1\Mozilla\Profiles\cap_j\foo.slt\nul goto CPJNETZ
cd\Windows\APPLIC~1\Mozilla\Profiles\cap_j\foo.slt
if not exist History.dat if not exist Cookies.txt if not exist prefs.bak goto CHKV7C
cd

if not exist prefs.bak echo No prefs.bak found
if not exist prefs.bak goto DV7HIS
c:\windows\command\choice /C:ync /N "prefs.bak exists. Delete? (y/n/c)>"
if errorlevel 3 goto FUP
if errorlevel 2 goto DV7HIS

c:\windows\command\Attrib -h prefs.bak
c:\windows\command\Attrib -r prefs.bak
del prefs.bak
if not exist prefs.bak echo prefs.bak was deleted.
if exist prefs.bak echo prefs.bak was not successfully deleted.

:DV7HIS
if not exist History.dat echo No History.dat found
if not exist History.dat goto CKV7CK
c:\windows\command\choice /C:ync /N "Netscape History exists. Delete? (y/n/c)>"
if errorlevel 3 goto FUP
if errorlevel 2 goto CKV7CK

c:\windows\command\Attrib -h History.dat
c:\windows\command\Attrib -r History.dat
del History.dat
if not exist History.dat echo Netscape History was deleted.
if exist History.dat echo Netscape History was not successfully deleted.

:CKV7CK
if not exist c:\bat\delnscck.bat echo c:\bat\delnscck.bat is required to delete Netscape cookies but was not found.
if exist c:\bat\delnscck.bat call c:\bat\delnscck.bat

:CHKV7C
if not exist cache\nul goto CPJNETZ
cd Cache
if not exist *.* goto CPJNETZ
cd
c:\Windows\Command\Attrib -h *.*
c:\Windows\Command\Attrib -r *.*
del .
echo.
REM This is the end of the Netscape ver 7.02 block

REM This is the Netscape ver 4.7 block
:CPJNETZ
if not exist c:\Progra~1\Netscape\Users\CAP_J\nul goto NZJUNK
cd\Progra~1\Netscape\Users\CAP_J
if not exist Netscape.hst if not exist Cookies.txt goto CHKCJC
cd

if not exist Netscape.hst echo No Netscape.hst found
if not exist Netscape.hst goto CHKNCK
c:\windows\command\choice /C:ync /N "Netscape History exists. Delete? (y/n/c)>"
if errorlevel 3 goto FUP
if errorlevel 2 goto CHKNCK

c:\windows\command\Attrib -h Netscape.hst
c:\windows\command\Attrib -r Netscape.hst
del Netscape.hst
if not exist Netscape.hst echo Netscape History was deleted.
if exist Netscape.hst echo Netscape History was not successfully deleted.

:CHKNCK
if not exist c:\bat\delnscck.bat echo c:\bat\delnscck.bat is required to delete Netscape cookies but was not found.
if exist c:\bat\delnscck.bat call c:\bat\delnscck.bat

:CHKCJC
if not exist cache\nul goto NZJUNK
cd Cache
if not exist *.* goto NZJUNK
cd
c:\Windows\Command\Attrib -h *.*
c:\Windows\Command\Attrib -r *.*
del .
echo.
REM This is the end of the Netscape ver 4.7 block

:NZJUNK
if not exist c:\bat\delnzjnk.bat echo c:\bat\delnzjnk.bat is required to delete Netzero junk but was not found.
if exist c:\bat\delnzjnk.bat call c:\bat\delnzjnk.bat

:SCBTMP
if not exist c:\progra~1\micros~1\office\shortc~1\nul goto PGPBAK
cd\progra~1\micros~1\office\shortc~1
if not exist *.tmp goto PGPBAK
cd
echo .tmp files found in C:\Program Files\Microsoft Office\Office\Shortcut Bar;
echo deleting...
c:\Windows\Command\Attrib -h *.tmp
c:\Windows\Command\Attrib -r *.tmp
del *.tmp
if exist *.tmp echo The .tmp files were not successfully deleted.
if not exist *.tmp echo All the .tmp files have been deleted.
echo.

:PGPBAK
if not exist c:\MYDOCU~1\PGP\nul goto WINTMP
cd\MYDOCU~1\PGP
if not exist ???rin~?.?kr goto WINTMP
cd
echo Deleting PGP Keyring backups...
if exist ???rin~?.?kr del ???rin~?.?kr

if not exist ???rin~?.?kr goto PGP1CONT
echo There are still more Keyring backups to delete!
pause
goto PGP2CONT
:PGP1CONT
echo All PGP Keyring backups cleared.
:PGP2CONT
echo.

REM ---------------------------------------------------------------------------------
REM Windows section. See gotos to WINTMP above
REM ---------------------------------------------------------------------------------

:WINTMP

REM Check if the whole Windows directory exists
if not exist c:\Windows\nul goto CTEMP

cd\Windows
if not exist *.tmp goto WINAPLG
cd
echo .tmp files found in C:\Windows; deleting...
c:\Windows\Command\Attrib -h *.tmp
c:\Windows\Command\Attrib -r *.tmp
del *.tmp
if exist *.tmp echo The .tmp files were not successfully deleted.
if not exist *.tmp echo All the .tmp files have been deleted.
echo.

:WINAPLG
if not exist c:\Windows\Applog\nul goto WINCOOK
cd\Windows\Applog
if not exist *.* goto WINCOOK
cd
c:\Windows\Command\Attrib -h *.*
c:\Windows\Command\Attrib -r *.*
del .
echo.

:WINCOOK
if not exist c:\bat\delwinck.bat echo c:\bat\delwinck.bat is required to delete Windows cookies but was not found.
if exist c:\bat\delwinck.bat call c:\bat\delwinck.bat

:WINHIST
if not exist c:\Windows\History\nul goto WINPRN
cd\Windows\History
if not exist *.* goto WINPRN
cd
c:\Windows\Command\Attrib -h *.*
c:\Windows\Command\Attrib -r *.*
del .
echo.

:WINPRN
if not exist c:\Windows\spool\PRINTERS\nul goto RECENT
cd\Windows\spool\PRINTERS
if not exist *.SHD goto RECENT
cd
echo ".SHD" files were found in c:\Windows\spool\PRINTERS\; deleting...
c:\Windows\Command\Attrib -h *.SHD
c:\Windows\Command\Attrib -r *.SHD
del *.SHD
if exist *.SHD echo SHD files were not deleted successfully!
if not exist *.SHD echo All SHD files were successfully deleted...
echo.

:RECENT
if not exist c:\Windows\Recent\nul goto WINTEMP
cd\Windows\Recent
if not exist *.* goto WINTEMP
cd
c:\Windows\Command\Attrib -h *.*
c:\Windows\Command\Attrib -r *.*
del .
echo.

:WINTEMP
echo.
if not exist c:\Windows\Temp\nul goto CTEMP
cd\Windows\Temp
if not exist *.* echo (No files found in c:\Windows\Temp - there may be subdirectories)
if exist *.* echo Files were found in c:\Windows\Temp...
cd
c:\windows\command\choice /C:ync /N "Delete any and all files and subdirectories in c:\Windows\Temp? (y/n/c)>"
if errorlevel 3 goto FUP
if errorlevel 2 goto CTEMP

if exist *.* c:\Windows\Command\Attrib -h *.*
if exist *.* c:\Windows\Command\Attrib -r *.*

echo echo Deleting (Using Deltree) and recreating c:\Windows\Temp in case there are subdirectories...
cd..
echo Deltree just says Temp, but it's c:\Windows\Temp;
c:\windows\command\deltree /Y Temp
if not exist Temp\nul goto MKWTEMP
echo Unable to delete c:\Windows\Temp.
cd Temp
echo Files remaining in c:\Windows\Temp:
dir /b
echo Hidden files in c:\Windows\Temp (if any):
dir /ah /b
goto CTEMP
:MKWTEMP
md Temp
echo ...recreated;


REM If adding anything before here not in c:\Windows, patch the statement above that
REM jumps around all the Windows stuff.

REM ---------------------------------------------------------------------------------
REM End of Windows section (except for JIM1, below). See gotos to CTEMP, above
REM ---------------------------------------------------------------------------------

:CTEMP
echo.
if not exist c:\Temp\nul goto JIM1
cd\Temp
if not exist *.* echo (No files found in c:\Temp - there may be subdirectories)
if exist *.* echo Files were found in c:\Temp...
cd
c:\windows\command\choice /C:ync /N "Delete any and all files and subdirectories in c:\Temp? (y/n/c)>"
if errorlevel 3 goto FUP
if errorlevel 2 goto JIM1

if exist *.* c:\Windows\Command\Attrib -h *.*
if exist *.* c:\Windows\Command\Attrib -r *.*

echo Deleting (Using Deltree) and recreating c:\Temp in case there are subdirectories...
cd..
echo Deltree just says Temp, but it's c:\Temp;
c:\windows\command\deltree /Y Temp
if not exist Temp\nul goto MKCTEMP
echo Unable to delete c:\Temp.
cd Temp
echo Files remaining in c:\Temp:
dir /b
echo Hidden files in c:\Temp (if any):
dir /ah /b
goto JIM1
:MKCTEMP
md Temp
echo ...recreated;

:JIM1
if not exist c:\Windows\Profiles\jim1~1\recent\nul goto FUP
cd\Windows\Profiles\jim1~1\recent
if exist *.* goto DOJIM1
echo (Nothing was found in "jim1" Recent Documents on the Start Button)
goto FUP
:DOJIM1
cd
del .


:FUP
echo.

echo done.
echo Remember, no personal files were deleted.
echo Remember the following personal files: [insert names of your personal files here]
echo and also Internet Exploiter
echo Cookies, Internet Exploiter Temporary Internet Files (ie the cache), Internet
echo Exploiter History, general .bak files, etc...
:END
echo.
echo Click on the X in the top right-hand corner of the Finished MS-DOS Window; that will clear it.

last updated June 9: added code to delete the c:\Windows\Applog
June 4: added code to delete .jpi cache
May 30: added some comments
May 26: added code to delete junk from ver 7.02 of Netscape, improved the deletion code for c:\Windows\Temp and added deletion code for c:\Temp
April 3, 2003