defrag and batch files

Hosinfefer

New Member
Hi guys

Im looking to run the windows defraag in a batch file and then running it in auto task thing.

is this right. I wrote it in notepad and called it defrag.bat copied to hard drive and then ran it manually. But it just shows a cmd promt and repeates the command over and over...but does not look like it really works


defrag -f c:\

thats it...then i save as. The f switch is to force it to scan even if it dont think the percentage needs to be scaned


thanks for the help
 
because its asks you questions...at 2 in the moring i am not up to answer...just want to it defrag...dont stop and ask me questions...hence the switch :)
 
What types of questions? Everything I've done with it runs fine...

EDIT - Ahh... you mean making it run automatically without you having to click "DEFRAGMENT"?
 
yea there u go...i dont want to have to click anything.. i want it to start once a week at 2 am and defrag both drives without me click one button...nothing at all on my part has to be done...so ws trying to write a stupid batch file...but i let mine run for 3 hours tonight. When i run it normal takes about 20 mins...so i doubt my batch is working. Any clues??
 
ok lets try this again with more detail.

I am wanting do use windows defrag to defrag my hard drive. Now when u start it will ask you questions about which drive u want to defrag and all that crap. So i want to use a batch file to auto run the defrag on my two drives with zero input from a user. Just like an automated install of windows. Now i know how to use task scheduled but there is no point in setting that up until i know for sure the batch file is working. So i wrote this file in notepad and then saved it as all files and named it defrag.bat this is what is in the file


defrag -f c:\
defrag -f e:\


now the switch f forces it to just defrag no questions. Now when i run this batch file manually by clicking on it in c:\ i get a mcd prompt that shows up and says defrag -f c:\ really fast over and over again. Now usually it take 20-30 mins to defrag my c drive )75 GB 10,000rpm) but it ran for over 3 hours and the fragment % didnt not change....so...does anyone know how to fix the batch file???
 
thanks for all the nice links. The only prob is most of it is for everything but xp. I have a computer mag that says to write defrag -f c:\ and one of the links say to write defrag c: -f.....im looking for people that know which one it is as it dont seem to be working. And thanks for the help for the smart butt comment about the google search but next time if all your going to do is post stupid respnse...dont bother...thanks
 
Your welcome, and all but one of them was for XP. The other was for 2000, but should still work.


And why would you put the command line -f before the drive? Every time I have done things like this it is always after the drive letter. Otherwise it does not know what to work on.
 
why would i do that...well according to smart computing vol 18 of decomeber 2007....that what it says to do..page 85 bottom half of page. But anyways i got it working...here is what it looks like


defrag.exe c: -f
defrag.exe e: -f

that will defrag my two drive. i save it and run it by clicking it and it works perfect. Now i go to sched task and set up the batch file called derag.bat to run at 2 am every week...never have to worry about defrag again :)

P.S. After running this...both drives came up with 0% frag...that is much better then other programs i have used...normally it always leaves some frags on there.

hope this helps someone
cheers
 
Back
Top