Automated Disk Optimizer

chaos945

OSNN Senior Addict
#1
Here is my automated cleaning file, it has been made generic as possible but you must have Spybot and Regcleaner installed to make use of all the options.

Download Regcleaner
Download Spybot

If the installation path of Spybot or Regcleaner is other than 'C:\Program Files' you'll need to specify otherwise in the file. Also if you have other drives besides C:, D:, E:, F:, G:, H: that need to be defragmented you'll need to specify otherwise in the file as well. If you don't want to use my EXE file you must run config.bat to use the Windows Cleanmgr.

The source is as follows: OLD, new version below
Code:
@echo off
echo Performing Spybot Operations...Please Wait
C:\Progra~1\Spybot~1\SpybotSD.exe /autoupdate /autoimmunize /autocheck /autofix /autoclose
cls
echo Cleaning Disk...Please Wait
cleanmgr /sagerun:n
del %TEMP%\*.* /q
del %TMP%\*.* /q
del %userprofile%\LOCALS~1\Tempor~1\*.* /q
del %userprofile%\LOCALS~1\History\*.* /q
del %SYSTEMROOT%\prefetch\*.* /q
cls
echo Cleaning Registry...Please Wait
C:\Progra~1\RegCleaner\RegCleanr.exe /Automatic Cleanup Mode
cls
echo -----------------
echo Defragmenting C:\
echo -----------------
defrag C:
cls
echo -----------------
echo Defragmenting E:\
echo -----------------
defrag E:
cls
echo -----------------
echo Defragmenting F:\
echo -----------------
defrag F:
cls
echo -----------------
echo Defragmenting G:\
echo -----------------
defrag G:
cls
echo -----------------
echo Defragmenting H:\
echo -----------------
defrag H:
cls
echo All Processes Complete
pause
Bugs:
* Cleanmgr.exe sometimes hangs, to continue with the cleaning process just end its task in the task manager
 

chaos945

OSNN Senior Addict
#2
Major update: added logic controls to the entire script.

It will let you know what is running and what was sucessfully ended.

Code:
@echo off
:: ENVIRONMENT VARIABLES
  set cleanmg=Disk Cleanup...Pending
  set tempo=  Delete files in %TEMP%...Pending
  set tmpo=  Delete files in %TMP%...Pending
  set historyo=  Clear History...Pending
  set prfetch=  Clear Prefetch...Pending
  set regcl=Clean the registry...Pending
  echo Please specify Disk Cleanup Options
  cleanmgr /sageset:n
  call
  cls

:: BEGIN SPYBOT
  set spybot=Performing Spybot Operations...Please Wait
  echo -- -- -- -- -- -- -- -- -- -- -- -- -- --
  echo %spybot%
  echo -- -- -- -- -- -- -- -- -- -- -- -- -- --
  echo %cleanmg%
  echo %tempo%
  echo %tmpo%
  echo %historyo%
  echo %prfetch%
  echo %regcl%
  echo Defragment all available drives...Pending
  C:\Progra~1\Spybot~1\SpybotSD.exe /autoupdate /autoimmunize /autocheck /autofix /autoclose
  if not errorlevel 1 goto success
  set spybot=Performing Spybot Operations...Failed
  goto next
:success
  set spybot=Performing Spybot Operations...Successful
:next
  cls
  echo %spybot%
  
:: BEGIN CLEANMGR
  set cleanmg=Cleaning Disk...Please Wait
  echo -- -- -- -- -- -- -- -- -- -- -- -- -- --  
  echo %cleanmg%
  echo -- -- -- -- -- -- -- -- -- -- -- -- -- --
  echo %tempo%
  echo %tmpo%
  echo %historyo%
  echo %prfetch%
  echo %regcl%
  echo Defragment all available drives...Pending
  cleanmgr /sagerun:n
  if not errorlevel 1 goto success
  set cleanmg=Cleaning Disk...Not all operations completed
  goto next
:success
  set cleanmg=Cleaning Disk...Successfull
:next
  del %TEMP%\*.* /q
  set tempo=  Delete files in %TEMP%...Success
  if not errorlevel 1 goto next
  set tempo=  Delete files in %TEMP%...Failed
:next
  del %TMP%\*.* /q
  set tmpo=  Delete files in %TMP%...Success
  if not errorlevel 1 goto next
  set tmpo=  Delete files in %TMP%...Failed
:next
  del %userprofile%\LOCALS~1\History\*.* /q
  set historyo=  Clear History...Success
  if not errorlevel 1 goto next
  set historyo=  Clear History...Failed
:next
  del %SYSTEMROOT%\prefetch\*.* /q
  set prfetch=  Clear Prefetch...Success
  if not errorlevel 1 goto next
  set prfetch=  Clear Prefetch...Failed
:next
  cls
  echo %spybot%
  echo %cleanmg%
  echo %tempo%
  echo %tmpo%
  echo %historyo%
  echo %prfetch%
  echo -- -- -- -- -- -- -- -- -- -- -- -- -- --
:: BEGIN REGCLEANR
  set regcl=Cleaning the registry...Please Wait
  echo %regcl%
  echo -- -- -- -- -- -- -- -- -- -- -- -- -- --
  echo Defragment all available drives...Pending
  C:\Progra~1\RegCleaner\RegCleanr.exe /Automatic Cleanup Mode
  if not errorlevel 1 goto success
  set regcl=Cleaning the registry...Failed
  goto next
:success
  set regcl=Cleaning the registry...Success
:next
  cls
  echo %spybot%
  echo %cleanmg%
  echo %tempo%
  echo %tmpo%
  echo %historyo%
  echo %prfetch%
  echo %regcl%
  echo -- -- -- -- -- -- -- -- -- -- -- -- -- --

:: BEGIN DEFRAG
:: Drive C:
  set status1=Defragmenting
  echo %status1% C:\
  echo -- -- -- -- -- -- -- -- -- -- -- -- -- --
  defrag C:
  if not errorlevel 1 goto success
  set status1=Failed to defragment
  goto next
:success
  set status1=Successfully defragmented
:next
  cls
  echo %spybot%
  echo %cleanmg%
  echo %tempo%
  echo %tmpo%
  echo %historyo%
  echo %prfetch%
  echo %regcl%
  echo %status1% C:\
  echo -- -- -- -- -- -- -- -- -- -- -- -- -- --
:: Drive D:
  set status2=Defragmenting
  echo %status2% D:\
  echo -- -- -- -- -- -- -- -- -- -- -- -- -- --
  defrag D:
  if not errorlevel 1 goto success
  set status2=Failed to defragment
  goto next
:success
  set status2=Successfully defragmented
:next
  cls
  echo %spybot%
  echo %cleanmg%
  echo %tempo%
  echo %tmpo%
  echo %historyo%
  echo %prfetch%
  echo %regcl%
  echo %status1% C:\
  echo %status2% D:\
  echo -- -- -- -- -- -- -- -- -- -- -- -- -- --
:: Drive E:
  set status3=Defragmenting
  echo %status3% E:\
  echo -- -- -- -- -- -- -- -- -- -- -- -- -- --
  defrag E:
  if not errorlevel 1 goto success
  set status3=Failed to defragment
  goto next
:success
  set status3=Successfully defragmented
:next
  cls
  echo %spybot%
  echo %cleanmg%
  echo %tempo%
  echo %tmpo%
  echo %historyo%
  echo %prfetch%
  echo %regcl%
  echo %status1% C:\
  echo %status2% D:\
  echo %status3% E:\
  echo -- -- -- -- -- -- -- -- -- -- -- -- -- --

:: Drive F:
  set status4=Defragmenting
  echo %status4% F:\
  echo -- -- -- -- -- -- -- -- -- -- -- -- -- --
  defrag F:
  if not errorlevel 1 goto success
  set status4=Failed to defragment
  goto next
:success
  set status4=Successfully defragmented
:next
  cls
  echo %spybot%
  echo %cleanmg%
  echo %tempo%
  echo %tmpo%
  echo %historyo%
  echo %prfetch%
  echo %regcl%
  echo %status1% C:\
  echo %status2% D:\
  echo %status3% E:\
  echo %status4% F:\
  echo -- -- -- -- -- -- -- -- -- -- -- -- -- --

:: Drive G:
  set status5=Defragmenting
  echo %status5% G:\
  echo -- -- -- -- -- -- -- -- -- -- -- -- -- --
  defrag G:
  if not errorlevel 1 goto success
  set status5=Failed to defragment
  goto next
:success
  set status5=Successfully defragmented
:next
  cls
  echo %spybot%
  echo %cleanmg%
  echo %tempo%
  echo %tmpo%
  echo %historyo%
  echo %prfetch%
  echo %regcl%
  echo %status1% C:\
  echo %status2% D:\
  echo %status3% E:\
  echo %status4% F:\
  echo %status5% G:\
  echo -- -- -- -- -- -- -- -- -- -- -- -- -- --

:: Drive H:
  set status6=Defragmenting
  echo %status6% H:\
  echo -- -- -- -- -- -- -- -- -- -- -- -- -- --
  defrag H:
  if not errorlevel 1 goto success
  set status6=Failed to defragment
  goto next
:success
  set status6=Successfully defragmented
:next
  cls
  echo %spybot%
  echo %cleanmg%
  echo %tempo%
  echo %tmpo%
  echo %historyo%
  echo %prfetch%
  echo %regcl%
  echo %status1% C:\
  echo %status2% D:\
  echo %status3% E:\
  echo %status4% F:\
  echo %status5% G:\
  echo %status6% H:\

:: END  
  echo -- -- --
  echo COMPLETE
  echo -- -- --
  pause
 

chaos945

OSNN Senior Addict
#3
More major changes:
* added interface!!!
* changed colours!!!!
* completly different logic
* if spybot or regclean is not found the download page opens itself
* added "**run all** option, only displays a summary at the end, then terminates on any key
* turned it back into just a BAT file no more EXE

I couldn't fit the entire source, but listed below is everything except the **run all** option.


Code:
@ECHO OFF
COLOR 17
TITLE RUNNING...
CLS
GOTO BEGIN_INPUT

:BEGIN_INPUT
	CLS
	ECHO.
	ECHO   ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
	ECHO   º CLEANUP OPTIONS:                  º
	ECHO   º 1.) SPYBOT - SEARCH AND DESTROY   º
	ECHO   º 2.) WINDOWS DISK CLEANUP          º
	ECHO   º 3.) CLEAR TEMP FILES              º
	ECHO   º 4.) DEFRAG ALL DRIVES             º
	ECHO   º 5.) REGCLEAN                      º
        ECHO   º 6.) **RUN ALL**                   º
	ECHO   º 7.) EXIT                          º
	ECHO   ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ
	ECHO.
	ECHO.
	@SET /P USER_INPUT="What would you like to do? "
		@IF /I "%USER_INPUT%"=="1" GOTO SPYBOTSTART
		@IF /I "%USER_INPUT%"=="one" GOTO SPYBOTSTART
		@IF /I "%USER_INPUT%"=="2" GOTO CLEANMGR
		@IF /I "%USER_INPUT%"=="two" GOTO CLEANMGR
		@IF /I "%USER_INPUT%"=="3" GOTO CLEARTMP
		@IF /I "%USER_INPUT%"=="three" GOTO CLEARTMP
		@IF /I "%USER_INPUT%"=="4" GOTO DEFRAGMENT
		@IF /I "%USER_INPUT%"=="four" GOTO DEFRAGMENT
		@IF /I "%USER_INPUT%"=="5" GOTO REGCLEAN
		@IF /I "%USER_INPUT%"=="FIVE" GOTO REGCLEAN
		@IF /I "%USER_INPUT%"=="6" GOTO MASS
		@IF /I "%USER_INPUT%"=="SIX" GOTO MASS
		@IF /I "%USER_INPUT%"=="SEVEN" GOTO EXIT
		@IF /I "%USER_INPUT%"=="7" GOTO EXIT
		@IF /I "%USER_INPUT%"=="E" GOTO EXIT
		@IF /I "%USER_INPUT%"=="EXIT" GOTO EXIT
	ECHO ERROR:Not a valid response
	PAUSE
	GOTO BEGIN_INPUT

:SPYBOTSTART
		@IF EXIST %SYSTEMDRIVE%\Progra~1\Spybot~1\SpybotSD.exe GOTO RUNSPYBOT
	ECHO !SPYBOTSD.exe NOT FOUND
	START [url]http://www.safer-networking.org/files/spybotsd13.exe[/url]
	PAUSE
	GOTO BEGIN_INPUT

:RUNSPYBOT	
	ECHO SPYBOTSD.EXE found starting program...
	%SYSTEMDRIVE%\Progra~1\Spybot~1\SpybotSD.exe /autoupdate /autoimmunize /autocheck /autofix /autoclose
		IF NOT ERRORLEVEL 1 GOTO SUCCESS
  	ECHO.
	ECHO  !SPYBOTSD.EXE failed to finish
	PAUSE
	GOTO BEGIN_INPUT

:SUCCESS
	ECHO.
	ECHO SPYBOTSD.EXE closed successfully
	PAUSE
	GOTO BEGIN_INPUT

:REGCLEAN
		@IF EXIST %SYSTEMDRIVE%\Progra~1\RegCleaner\RegCleanr.exe GOTO RUNCLEAN
	ECHO !REGCLEANR.EXE NOT FOUND
	START [url]http://www.majorgeeks.com/download460.html[/url]
	PAUSE
	GOTO BEGIN_INPUT

:RUNCLEAN
	ECHO REGCLEANR.EXE.EXE found starting program...
	%SYSTEMDRIVE%\Progra~1\RegCleaner\RegCleanr.exe /Automatic Cleanup Mode
		IF NOT ERRORLEVEL 1 GOTO SUCCESS
	ECHO.
	ECHO  !REGCLEANR.EXE failed to finish
	PAUSE
	GOTO BEGIN_INPUT

:SUCCESS
	ECHO.
	ECHO REGCLEANR.EXE closed successfully
	PAUSE
	GOTO BEGIN_INPUT

:CLEANMGR
		@IF EXIST %TEMP%.\SETDONE GOTO RUNCLEANMGR 
	ECHO !Configure CLEANMGR before proceeding
	CLEANMGR /SAGESET:N
	MD %TEMP%.\SETDONE
		IF ERRORLEVEL 1 GOTO RUNCLEANMGR
		IF NOT ERRORLEVEL 1 GOTO RUNCLEANMGR

:RUNCLEANMGR
	CLEANMGR /SAGERUN:N
		IF NOT ERRORLEVEL 1 GOTO SUCCESS
	ECHO.
	ECHO !CLEANMGR.EXE failed to finish
	PAUSE
	GOTO BEGIN_INPUT
:SUCCESS
	ECHO.
	ECHO CLEANMGR.EXE closed successfully
	PAUSE
	GOTO BEGIN_INPUT

:CLEARTMP
	DEL %TEMP%\*.* /q
	SET TEMPO=úDelete files in %TEMP% successful
		IF NOT ERRORLEVEL 1 GOTO NEXT
	SET TEMPO=!Delete files in %TEMP% failed
  :NEXT
	DEL %TMP%\*.* /q
	SET TMPO=úDelete files in %TMP% successful
		IF NOT ERRORLEVEL 1 GOTO NEXT
	SET TMPO=!Delete files in %TMP% failed
  :NEXT
	DEL %SYSTEMROOT%\prefetch\*.* /q
	SET PRFETCH=úClear prefetch successful
		IF NOT ERRORLEVEL 1 GOTO NEXT
	set PRFETCH=!Clear prefetch failed
  :NEXT
	ECHO.
	ECHO %TEMPO%
	ECHO %TMPO%
	ECHO %PRFETCH%
	PAUSE
	GOTO BEGIN_INPUT


:DEFRAGMENT
	CLS
	SET status1=Defragmenting
	echo %status1% C:\
	echo -- -- -- -- -- -- -- -- -- -- -- -- -- --
	defrag C:
	if not errorlevel 1 goto success
	set status1=!Failed to defragment
	goto next
  :success
	set status1=úSuccessfully defragmented
  :next
	cls
	echo %status1% C:\
	ECHO.
	set status2=Defragmenting
	echo -- -- -- -- -- -- -- -- -- -- -- -- -- --
	echo %status2% D:\
	echo -- -- -- -- -- -- -- -- -- -- -- -- -- --
	defrag D:
	if not errorlevel 1 goto success
	set status2=!Failed to defragment
	goto next
:success
	set status2=úSuccessfully defragmented
:next
	cls
	echo %status1% C:\
	Echo %status2% D:\
	ECHO.
	echo -- -- -- -- -- -- -- -- -- -- -- -- -- --
	set status3=Defragmenting
	Echo %status3% E:\
	echo -- -- -- -- -- -- -- -- -- -- -- -- -- --
	defrag E:
	if not errorlevel 1 goto success
	set status3=!Failed to defragment
	goto next
:success
	set status3=úSuccessfully defragmented
:next
	cls
	echo %status1% C:\
	echo %status2% D:\
	echo %status3% E:\
	ECHO.
	set status4=Defragmenting
	echo -- -- -- -- -- -- -- -- -- -- -- -- -- --
	echo %status4% F:\
	echo -- -- -- -- -- -- -- -- -- -- -- -- -- --
	defrag F:
	If not errorlevel 1 goto success
	set status4=!Failed to defragment
	goto next
:success
	set status4=úSuccessfully defragmented
:next
	cls
	echo %status1% C:\
	echo %status2% D:\
	echo %status3% E:\
	echo %status4% F:\
	ECHO.
	set status5=Defragmenting
	echo -- -- -- -- -- -- -- -- -- -- -- -- -- --
	echo %status5% G:\
	echo -- -- -- -- -- -- -- -- -- -- -- -- -- --
	defrag G:
	If not errorlevel 1 goto success
	set status5=!Failed to defragment
	goto next
:success
	set status5=úSuccessfully defragmented
:next
	cls
	echo %status1% C:\
	echo %status2% D:\
	echo %status3% E:\
	echo %status4% F:\
	echo %status5% G:\
	ECHO.
	set status6=Defragmenting
	echo -- -- -- -- -- -- -- -- -- -- -- -- -- --
	echo %status6% H:\
	echo -- -- -- -- -- -- -- -- -- -- -- -- -- --
	defrag H:
	if not errorlevel 1 goto success
	set status6=!Failed to defragment
	goto next
:success
	set status6=úSuccessfully defragmented
:next
	cls
	echo %status1% C:\
	echo %status2% D:\
	echo %status3% E:\
	echo %status4% F:\
	echo %status5% G:\
	echo %status6% H:\
	ECHO.
	PAUSE
	GOTO BEGIN_INPUT

::::::::::::::::::::::::::::::::::::::::
 

yoyo

_________________
#5
Nice work.

Just one question. Why did you include prefetch? Deleting the files in this folder defeats the purpose of prefetch.
 

Perris Calderon

Administrator
Staff member
Political User
#6
/agrees with yoyo , in both regards chaos...it is nice work, and also agrees with him about no benefit to deleating the prefetch contents

that "clear prefetch" is a counter productive tweak...personally, I don't think it should be done at all, but if at all, maybe once every couple of months at the most;

Windows XP speeds up system boot by observing the code and data needed each time the system is booted and prefetching the necessary file contents early in the boot process...it will also put this info on an optimum spot on the disk

it will then defrag the prefetch info.

now, does deleting this folder still make sense?...optimization on disc will have to begin all over again when this file is deleted

my operating systems are definately faster a couple of months into the install then the beginning, and prefetch is one of the reasons

I'll tell you what is an excellant item to include;

Code:
%windir%\Prefetch\Layout.ini
in cmd or run will perform this native "disc optimization" all at once.

this usually doesn't happen but for once every three days, so this item would be nice in your file

be advised however, the disc optimizations in xp do not cross volume, so though the do some good on partitioned drives, for the most part, your applications need to be on "c" in order to get full benenfit.

this is the main reason some people do not notice a gain with prefetch enabled

but ya chaos really nice job
 

chaos945

OSNN Senior Addict
#7
Thanks for the input all, I think I'll be figuring out a different programming language pretty quick here to make a nice easy interface.

I did some minor improvements, but I wasn't exactly sure how to implement that Layout.ini function.
*interface revisions
*spelling revisions
*main menu's logic and response to errors
*removed prefetch in options 3 + 6
 

Dark Atheist

OSNN Veteran Addict
Staff member
Political User
#8
nice tool found it and used it this morn - saves me clicking here there and everywhere to run the same progs, one little suggestion/idear - how about adding adaware to the list - if its possible that is?

Have already sent it to a few friends and they v happy with it also :)
 

chaos945

OSNN Senior Addict
#9
New Release

I decided the script was getting a bit bloated so I dumbed the entire thing back down to what it was supposed to be in the first place, an easy way to automatically run the disk services I wanted.

All directories are defaulted to the %systemdrive% that would be 'C:' in most people's cases. Instead of making the entire thing one big script, I broke each program up into it's own module that can be removed or added to. I've also added documentation to the modules so anyone can easlity add functinality to the scripts, ie, more drives cleaned/defraged, or adding custom modules.

New version:
* Installer/Uninstaller
* New Interface
* added Adware support
* defrag only defrags 'C:' (unless otherwise specifed)
* adware only scans 'C:' (unless otherwise specifed)
 

chaos945

OSNN Senior Addict
#10
This is going to be the last release for a while. There are very few bugs left, even as picky as I am. Read the official ‘Read Me’ file in the package for more documentation. It was quite an interesting development, but I’m glad it’s finally coming to an end, and am quite happy with the final result. Thank you for your support.

Features (tested only on the listed version, may or may not work on others):
  • Installer/Uninstaller
  • Adware 6 – ‘Ad-Aware.EXE "<mounteddrive>:\" +a +s +1’
  • Regcleaner 4.3 – ‘RegCleanr.exe /Automatic Cleanup Mode’
  • Spybot 1.3 beta 6 – ‘SpybotSD.exe /autoimmunize /autocheck /autofix /autoclose’
    ( /autoupdate will be added when 1.3 comes out, it is buggy in the beta still)
  • Windows Clean Manager – ‘cleanmgr.exe /sageset:n’, ‘cleanmgr.exe /sagerun:n’
  • Windows Defragmenter – ‘defrag <mounteddrive>’
  • DIRMS – ‘DIRMS <mounteddrive> compact defrag’

Added in this version:
  • Revised installer package, misc things, startup shortcut, run after install…etc
  • Revised documentation, most of it is in the Read Me
  • Spybot does not need a install path, it will find itself
  • DIRMS module added
  • To make things a bit easier for those not as familiar with batch scripting ‘paths.bat’ has been added. Just modify the path for Adware and Regcleaner if it is not on the %systemdrive%, which is ‘C:\’ for most of you
  • All modules and misc scripts have been cleaned up, the documentation is under REMs
  • The DIRMS, defragmenter and ad-ware modules will find any available drives and defrag/cleanup them all
Known Bugs:
  • Adware and Regcleaner will not find themselves if they are not on the %systemdrive% they will not work on a different path unless the paths.bat file is modified
  • ‘Error: Invalid key name’, this happens after the reg key for disabling file compression already has been deleted, nothing has gone wrong.
  • Spybot does not like you having Ad-ware installed, it will actually warn you itself, if you want to remove one or the other from the routine just move the module into the DISABLED folder
 

Members online

No members online now.

Latest posts

Latest profile posts

Perris Calderon wrote on Electronic Punk's profile.
Ep, glad to see you come back and tidy up...did want to ask a one day favor, I want to enhance my resume , was hoping you could make me administrator for a day, if so, take me right off since I won't be here to do anything, and don't know the slightest about the board, but it would be nice putting "served administrator osnn", if can do, THANKS

Been running around Quora lately, luv it there https://tinyurl.com/ycpxl
Electronic Punk wrote on Perris Calderon's profile.
All good still mate?
Hello, is there anybody in there? Just nod if you can hear me ...
Xie
What a long strange trip it's been. =)

Forum statistics

Threads
61,970
Messages
673,297
Members
89,017
Latest member
Poseeut