How To: Set up to automatically defragment
Learn from our various Guides, plus check out our FAQ's and How To's. There is something for everyone. Share what you know and add to the collection.

Moderators: Management, Forum Experts

How To: Set up to automatically defragment

Postby gries818 on Sat Apr 22, 2006 7:29 pm

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.
Last edited by gries818 on Tue May 02, 2006 12:11 pm, edited 1 time in total.
User avatar
gries818
Support Team
 
Posts: 5986
Joined: Wed Jul 07, 2004 1:28 pm

Re: How To: Set up to automatically defragment

Postby l33t on Sun Apr 23, 2006 10:13 am

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 :eek: )


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?
Last edited by l33t on Tue May 02, 2006 5:47 pm, edited 1 time in total.
User avatar
l33t
PRO Level 14
PRO Level 14
 
Posts: 974
Joined: Sun May 01, 2005 9:06 pm

Postby gries818 on Sun Apr 23, 2006 12:09 pm

defragmenting twice and defragmenting the boot record, excellent, i shall try that.
Image

Mac OS 10.5.6 - Personal
Ubuntu Server 9.04 - Server
User avatar
gries818
Support Team
 
Posts: 5986
Joined: Wed Jul 07, 2004 1:28 pm

Postby l33t on Sun Apr 23, 2006 12:56 pm

gries818 wrote:defragmenting twice and defragmenting the boot record, excellent, i shall try that.


it certanly does help. some people say that dowing it twice just takes more time and dosent work, so i always point out

why does the second pass take a while if "it dosent do anything"
because, it IS doing something....
User avatar
l33t
PRO Level 14
PRO Level 14
 
Posts: 974
Joined: Sun May 01, 2005 9:06 pm

Postby gries818 on Tue May 02, 2006 12:11 pm

the defrag for the mbr actually improves my bootup speed alot.
Image

Mac OS 10.5.6 - Personal
Ubuntu Server 9.04 - Server
User avatar
gries818
Support Team
 
Posts: 5986
Joined: Wed Jul 07, 2004 1:28 pm

Postby augie on Tue May 02, 2006 12:54 pm

Whenever I defrag, I notice improvements up to five defrags.
Some days you're the dog...Some days you're the hydrant.- by someone.

P5Q-Pro, Q6600, 4X 1GB PC8500, 2X eVGA 9800GT @1800 shaders, Vista X86 Ult.
A8N-E, X2 3800+, 2X 512MB, eVGA GTX 260-216 @ 1550 shaders, W7 X86 Ult.
User avatar
augie
Community Director
 
Posts: 13033
Joined: Sun Aug 25, 2002 8:55 pm
Location: Laurentians, Quebec

Postby gries818 on Tue May 02, 2006 1:10 pm

wow, i shall try that.
Image

Mac OS 10.5.6 - Personal
Ubuntu Server 9.04 - Server
User avatar
gries818
Support Team
 
Posts: 5986
Joined: Wed Jul 07, 2004 1:28 pm

Postby e to the x on Tue May 02, 2006 1:19 pm

Sounds like a good night time activity for my computer. 5 defrags/drive and a few for the boot sector. rock on.

@ L33t. That coding you have there in your post. Is that what you actually entered into the batch file? You can use the
Code: Select all
[code][/code]
tags if it is ot make it clearer what gets copied into the notepad when making the .bat ;)
Image
~Main Rig~
Quad Q8200
Asus P5Q3 P45
8 GB Corsair DDR3-1333
eVGA 9800GT
3x250GB HDD
WinXP; W7 x64
~Audio Stream Rig~
Athlon XP 2000+
MSI Motherboard
1 GB DDR-400
SoundBlaster Audigy2
160 GB HDD
WinXP
User avatar
e to the x
PROfessional Member
 
Posts: 6346
Joined: Mon Oct 18, 2004 12:55 pm
Location: Long Island, NY

Postby gries818 on Tue May 02, 2006 1:44 pm

Yeah, you can set it to run in the Scheduled Tasks. Thats how I have mine set up anyway.
Image

Mac OS 10.5.6 - Personal
Ubuntu Server 9.04 - Server
User avatar
gries818
Support Team
 
Posts: 5986
Joined: Wed Jul 07, 2004 1:28 pm

Postby l33t on Tue May 02, 2006 5:42 pm

e to the x wrote:Sounds like a good night time activity for my computer. 5 defrags/drive and a few for the boot sector. rock on.

@ L33t. That coding you have there in your post. Is that what you actually entered into the batch file? You can use the
Code: Select all
[code][/code]
tags if it is ot make it clearer what gets copied into the notepad when making the .bat ;)


will do (i didnt know the code tags were there) :eek:
i was thinking... does anybody know how to make it so that a program will run something XXX numeber of times?

like have a batch file (say for example) defrag.bat
so at the run box you owuld just have to type defrag.bat 5 and it would run 5 times?

i *think* i know how but i have to *write* a research paper 2night (6 pages...)

if i get time i will mess around with it..
[/code]
User avatar
l33t
PRO Level 14
PRO Level 14
 
Posts: 974
Joined: Sun May 01, 2005 9:06 pm

Next

Return to Guides and How To

Who is online

Users browsing this forum: No registered users and 0 guests

cron