Windows 7 Forums
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: Batch file to cleanup OS temp and junk files.

27 Jun 2019   #1
Paul Black

Win 7 HP SP1 64-bit Vista HB SP2 32-bit Linux Mint 18.3
 
 
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.




My System SpecsSystem Spec
.
27 Jun 2019   #2
torchwood

W7 home premium 32bit/W7HP 64bit/w10 tp insider ring
 
 

Hi Paul,

you could use this fixlist via FRST

Start::
CreateRestorePoint:
CloseProcesses:

EmptyTemp:
End::



Roy
My System SpecsSystem Spec
28 Jun 2019   #3
Paul Black

Win 7 HP SP1 64-bit Vista HB SP2 32-bit Linux Mint 18.3
 
 

Hi torchwood,

Quote   Quote: Originally Posted by torchwood View Post
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 System SpecsSystem Spec
.

28 Jun 2019   #4
samuria

win 8 32 bit
 
 

Just use uncleaner it does it all and it's free https//m.majorgeeks.com/files/details/uncleaner.html
My System SpecsSystem Spec
28 Jun 2019   #5
RoWin7

Win 7 Ult 64-bit
 
 

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 System SpecsSystem Spec
28 Jun 2019   #6
RoWin7

Win 7 Ult 64-bit
 
 

You are aware that Iobit is a Chinese company, right?
My System SpecsSystem Spec
29 Jun 2019   #7
Paul Black

Win 7 HP SP1 64-bit Vista HB SP2 32-bit Linux Mint 18.3
 
 

Hi RoWin7,

Quote   Quote: Originally Posted by RoWin7 View Post
[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!

Quote   Quote: Originally Posted by RoWin7 View Post
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 System SpecsSystem Spec
.
29 Jun 2019   #8
torchwood

W7 home premium 32bit/W7HP 64bit/w10 tp insider ring
 
 

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 System SpecsSystem Spec
29 Jun 2019   #9
Paul Black

Win 7 HP SP1 64-bit Vista HB SP2 32-bit Linux Mint 18.3
 
 

Hi torchwood,

Quote   Quote: Originally Posted by torchwood View Post
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.

Quote   Quote: Originally Posted by torchwood View Post
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!

Quote   Quote: Originally Posted by torchwood View Post
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 System SpecsSystem Spec
29 Jun 2019   #10
Paul Black

Win 7 HP SP1 64-bit Vista HB SP2 32-bit Linux Mint 18.3
 
 

Hi torchwood,

Quote   Quote: Originally Posted by torchwood View Post
@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 System SpecsSystem Spec
Reply

 Batch file to cleanup OS temp and junk files.




Thread Tools




Similar help and support threads
Thread Forum
IE11 Saved Passwords gone after cookie/temp files cleanup
hi there, why does IE11 remove all web passwords when you use CC cleaner and the option "saved passwords" is UNTICKED? it seems as though it's ignoring that, unless they are stored elsewhere and they get cleaned with temp files and company cleanup. That setting seems to work for Chrome and...
Browsers & Mail
Advanced Disk Cleanup - Create Shortcuts Without A Batch File!
Hello 7, This is how to create shortcuts for the Advanced Disk Cleanup feature. I keep mine in my Start Menu :geek: These shortcuts do not require batch files or command window, and they execute immediately. Just follow the steps below! NOTE: You MUST be logged in as an administrator to...
Performance & Maintenance
Disk cleanup, difference between temp file options + concerns
Hey guys, im kinda confused how these 2 differentiate. I know that programs use temp files to load faster and sometimes refuse to delete on computer shutdown so its not my problem there. My problem is what is the difference between temp files and temporary internet files? Is temporary internet...
Performance & Maintenance
IE11 Saved Passwords gone after cookie/temp files cleanup
hi there, I would like to know if it's normal that after doing a "maintenance" cleanup on the pc, Ccleaner & PC tools "Clen Your Disk" option, (cookie/temp files, etc), then IE11 will lose all saved passwords. on Ccleaner the option "Saved Password" is UNticked. On Chrome and Firefox...
Browsers & Mail
Temp folder getting filled with batch files
Hello, My temporary folder has been have batch files created in it every 15 seconds or so. My mouse is the arrow with the busy circle at 2'oclock of it constantly, so something is running. I checked my processes and they seemed to all be normal. I updated everything including windows.net 4 so I...
General Discussion


Our Sites

Site Links

About Us

Find 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 08:32.
Twitter Facebook