gries818 wrote:I wanted to set up my comptuer to defragment my hard drives on a weekly basis but could not find out anyway to do this without buying 3rd party defragmentors. So I came up with my own solution simple solution to my problem. This quick guide assumes you know fairly basic things about Windows.
1. Create a new batch file with Notepad. Add this:
- Code: Select all
@echo off
defrag C:\
exit
Note: This will bring up a console window run the command line defragmenter and close after it is done. You can add more drives to defragment by adding defrag (volume) after defrag C:\
2. Go to Scheduled Tasks and add the batch file to the scheduled tasks. You can go ahead and schedule for whenever.
Please go ahead and post any easier solutions if you have them.
*edit*
This code works correctly on my system. Please inform me if it doesn't on yours. That said, I can't imagine why it wouldn't work correctly on your system.
it works, but why not make it better?
instead od JUST defrag C:
put theese two flags (theese myst be run as different commands...)
defrag %drive%: -v
defrag %drive%: -b
where %drive% is the hard disk(s) that you want to defragment.
the -v (verboose) command is not needed, but it give me some stastics ( i like numbers, and the statistics remind me of my favorite OS (linux has lots of information...))
the -b (boot) flag will not desplay anyinformation, it is for the BOOt partition. it defrags the MBR (for slightly faster boots).
uhh, i did benchmarks, and i founds that windows disk defragmentor dosent do a 100% job on the first time, so you must fo it twice (and up to five times acording to to others

)
here is the source from my program (er, not a program, just a batch file)
- Code: Select all
@echo off
color 0a
title defragger (1.4) pass 1
echo now defragging C:\ drive or mount
echo this will only perform ONE pass, then restart and do a secoond
echo RUN ME WEEKLY (more freaquently is better!)
title defragger (1.4) pass 1 C:
defrag C: -v -b
defrag c: -v
title defragger (1.4) pass 1 E:
defrag E: -v -b
defrag E: -v
title defragger (1.4) pass 1 G:
defrag G: -v -b
defrag G: -v
echo, finished with pass one
cls
title defragger (1.4) pass 2 C:
defrag C: -v -b
defrag c: -v
title defragger (1.4) pass 2 E:
defrag E: -v -b
defrag E: -v
title defragger (1.4) pass 2 G:
defrag G: -v -b
defrag G: -v
echo pass 2 DONE
echo all done
echo DONE!
pause
there.....
that scans all three of my local "drives" twice...
the local drive, and the boot partition.
if you dont need the other drives, then delete that part of the code (or comment it out)
i also put it in the title, which drive its on and which pass. the 1.4 is for the version (i change programs all the time, and i need to keep track twith a version number)
enjoy!
i cant figure how to uppload a file... tell me and ill give you my proggie (i will add directions to cutomise it for your system)
PS: does anybody know how to make a batch file quwery the computer to get a list of all current hard disks pluggged in?