Batch file to cleanup OS temp and junk files.

Page 1 of 3 123 LastLast

  1. Posts : 6,021
    Win 7 HP SP1 64-bit Vista HB SP2 32-bit Linux Mint 18.3
       #1

    Batch file to cleanup OS temp and junk files.


    I am one who likes to keep my computers clean and running smoothly. All my files/folders etc are super organised and tidy [and yes, I do have OCD].

    On a weekly basis I run ...

    [1] Extended Disk Cleanup using a batch file.
    [2] CCleaner [excluding the registry cleaner].
    [3] Glary Utilities [excluding the registry cleaner].
    [4] Clear ALL the Event Viewer logs using a batch file.

    Note: Before anyone mentions the fact that these logs are useful if a problem arises for troubleshooting, I know that, and this is not the point of this post.

    [5] Defragment.
    [6] AVG.
    [7] Malwarebytes.
    [8] Backup my data etc.

    Although the above does a great job, I wondered if creating a batch [.bat] file to remove ALL the temp and junk files that the above doesn't do would also be of an advantage!

    I investigated this option and found many many scripts that claim that they do this with no detrimental downside or knock on affect at all. I tried some that stated this and they certainly didn't do what was stated and expected and they certainly did have a detrimental downside or knock on affect. In these cases I just restored my customised master system image [takes about 10 minutes].

    Here is a script [I have just changed it slightly] that I ran on my Vista test computer that seems/appears to be quite good. I have attached the output given.

    WARNING: Do NOT run the script below unless you understand batch script and know exactly what it will do. If you do run it, I advise you to make a System Image FIRST, just in case of problems or it has a detrimental downside or knock on affect!

    Source => Computer Junk Files Cleaner – DIY Small Tool To Clean Junk Files In Computer.

    Code:
    @echo off
    if not "%1" == "max" start /MAX cmd /c %0 max & exit/b
    echo.
    echo Cleaning system junk files, please wait . . .
    echo.
    del /f /s /q %systemdrive%\*.tmp
    del /f /s /q %systemdrive%\*._mp
    del /f /s /q %systemdrive%\*.log
    del /f /s /q %systemdrive%\*.gid
    del /f /s /q %systemdrive%\*.chk
    del /f /s /q %systemdrive%\*.old
    del /f /s /q %systemdrive%\recycled\*.*
    del /f /s /q %windir%\*.bak
    del /f /s /q %windir%\prefetch\*.*
    rd /s /q %windir%\temp & md %windir%\temp
    del /f /q %userprofile%\cookies\*.*
    del /f /q %userprofile%\recent\*.*
    del /f /s /q “%userprofile%\Local Settings\Temporary Internet Files\*.*”
    del /f /s /q “%userprofile%\Local Settings\Temp\*.*”
    del /f /s /q “%userprofile%\recent\*.*”
    echo.
    echo Junk files clean is finished!
    echo. & pause
    Results produced from the above run on my test system => Clean System Junk Files - RESULTS.txt.

    I just wondered what you think about ...

    [1] What it cleans.
    [2] Whether or not it should clean what it does.
    [3] Is there any detrimental downside or knock on affect.
    [4] Are there any other items that can be safely included.

    I have a few more items that could possibly be added which I may post at a later stage depending on the feedback received with regard to the above!

    Thanks.
    Last edited by Paul Black; 07 Jul 2019 at 03:11. Reason: Added WARNING!
      My Computer


  2. Posts : 7,107
    W7 home premium 32bit/W7HP 64bit/w10 tp insider ring
       #2

    Hi Paul,

    you could use this fixlist via FRST

    Start::
    CreateRestorePoint:
    CloseProcesses:

    EmptyTemp:
    End::



    Roy
      My Computer


  3. Posts : 6,021
    Win 7 HP SP1 64-bit Vista HB SP2 32-bit Linux Mint 18.3
    Thread Starter
       #3

    Hi torchwood,

    torchwood said:
    You could use this fixlist via FRST.
    Thanks for the reply. However, FRST is mainly used for the diagnostics of malware and its ability to fix boot issues. The main idea of this thread is to produce a batch file that will clear all the temporary files and junk files [that other programs may not do] and has no detrimental downside or knock on affect to the running of the OS.
      My Computer


  4. Posts : 3,786
    win 8 32 bit
       #4

    Just use uncleaner it does it all and it's free https//m.majorgeeks.com/files/details/uncleaner.html
      My Computer


  5. Posts : 1,384
    Win 7 Ult 64-bit
       #5

    I keep my machines tidy too. In addition to cleaning, all personal shortcuts, folders and files have logical names and I have an easy-to-navigate filing system that I've maintained since Win 98.

    I just removed FRST from my machine because I didn't remember downloading it and didn't know what it does.

    How about the program TFC? Download TFC

    How would I run your program? in the cmd window? I don't want to kill the CBS.log because I haven't been able to install security updates in over a year. How would I create an exception?
      My Computer


  6. Posts : 1,384
    Win 7 Ult 64-bit
       #6

    You are aware that Iobit is a Chinese company, right?
      My Computer


  7. Posts : 6,021
    Win 7 HP SP1 64-bit Vista HB SP2 32-bit Linux Mint 18.3
    Thread Starter
       #7

    Hi RoWin7,

    RoWin7 said:
    [1] How would I run your program? in the [2] cmd window? I don't want to kill the CBS.log because I haven't been able to install security updates in over a year. [3] How would I create an exception?
    [1] It isn't my program. It is from the source that I posted.
    [2] Yes, from an elevated command prompt.
    [3] You could probably rename the suffix to something else that isn't currently included in the cleaning criteria, something like .zzz for example, and then revert it back to .log after you have run the program.

    As I said, this is not my program, so if you are going to run it I would backup your OS first.
    The program performs more of a generalised clean, rather than a specific clean.
    A program can be written to only clean specific items of temp and junk files. I might decide to do something like that one day, but for now, I am just intereted in seeing if the generalised clean has any detrimental downside or knock on affect, and possibly if other items can be added/removed from it!

    RoWin7 said:
    You are aware that Iobit is a Chinese company, right?
    Yes I do! I have used IOBIT Smart Defrag etc in the past without any issues.
      My Computer


  8. Posts : 7,107
    W7 home premium 32bit/W7HP 64bit/w10 tp insider ring
       #8

    Hi

    I've used TFC, (really old prog) for years, and 1 click event cleaner, Brinks TUT.
    As for Iobit thier defrag/uninstaller are really good, they got creamed because of the MWB AV debacle, they now use Bitdefender UNDER LICIENCE.
    (ps it was started by a couple of Americans, moved to China coz it was less regulated)

    As for FRST well granted its primarilly antimalware tool, just using the FIX option turns it into a Batch script prog

    Roy
    @RoWin7 post the CBS i'll look it over, are normal updates installing??
      My Computer


  9. Posts : 6,021
    Win 7 HP SP1 64-bit Vista HB SP2 32-bit Linux Mint 18.3
    Thread Starter
       #9

    Hi torchwood,

    torchwood said:
    I've used TFC, (really old prog) for years, and 1 click event cleaner, Brinks TUT.
    I will have a closer look at TFC [Temp File Cleaner]. It would be nice if I can get to see the script if it is open source.

    torchwood said:
    As for Iobit thier defrag/uninstaller are really good, they got creamed because of the MWB AV debacle, they now use Bitdefender UNDER LICIENCE.
    (ps it was started by a couple of Americans, moved to China coz it was less regulated)
    For uninstalling I use Revo Uninstaller because you can run the Advanced Scan option to scan for leftover items which is excellent!

    torchwood said:
    As for FRST well granted its primarilly antimalware tool, just using the FIX option turns it into a Batch script program.
    Again, I will have a closer look at FRST [Farbar Recovery Scan Tool]. It would be nice if I can get to see the script if it is open source.
      My Computer


  10. Posts : 6,021
    Win 7 HP SP1 64-bit Vista HB SP2 32-bit Linux Mint 18.3
    Thread Starter
       #10

    Hi torchwood,

    torchwood said:
    @RoWin7 post the CBS i'll look it over, are normal updates installing?
    Would you be interested in or find this useful!

    I know that you are one of the few members here that can analise and diagnose the CBS.log. I have written a batch program that will extract the errors ONLY from the CBS.log. SFC [System File Checker] MUST obviously be run BEFORE running the batch program. The batch program creates a sfc_details.txt file on the desktop. Would it help you to analise and diagnose problems of the CBS.log that members are asked to upload here at SevenForums because it will only contain the exracted errors?
      My Computer


 
Page 1 of 3 123 LastLast

  Related Discussions
Our Sites
Site Links
About Us
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 18:41.
Find Us