Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 SQL Server Administration (2005)
 Automating Defrag.exe

Author  Topic 

CanadaDBA

583 Posts

Posted - 2007-07-19 : 09:44:00
Isn't there any way to automate Windows defrag? Isn't there any undocumented parameters for DEFRAG.EXE?

Canada DBA

Haywood
Posting Yak Master

221 Posts

Posted - 2007-07-19 : 10:10:55
This is a batchfile I use to keep my craptop defragged...

Defrag C: -f -v > C:\Utils\Defrag\Defrag.out.txt
Defrag D: -f -v >> C:\Utils\Defrag\Defrag.out.txt
Go to Top of Page

CanadaDBA

583 Posts

Posted - 2007-07-19 : 10:22:55
That's good and I guess I can put it in a batch file and schedule it. I'll try it. Thanks!

Meanwhile, I found the following on the net.

http://searchwincomputing.techtarget.com/originalContent/0,289142,sid68_gci1097119,00.html

http://snippets.dzone.com/posts/show/3925


Canada DBA
Go to Top of Page

Haywood
Posting Yak Master

221 Posts

Posted - 2007-07-19 : 10:26:26
The first link is exactly what I do...

Can't get to the second link due to websense.
Go to Top of Page

CanadaDBA

583 Posts

Posted - 2007-07-19 : 15:09:27
The autodefrag.py does not run under Windows and needs another program to be installed. But using Haywood's solution, I created the following batch file that can be scheduled and run.

@Echo off
SET DestPath=C:\Utils\Defrag.out.txt
Date /T >> %DestPath%
Time /T >> %DestPath%
Echo ------------------------------- >> %DestPath%
Defrag C: -f -v >> %DestPath%
Echo ***Finished*** >> %DestPath%
Time /T >> %DestPath%
Echo ------------------------------- >> %DestPath%
Echo * * * * * * * * * * * * * * * * >> %DestPath%
Echo ------------------------------- >> %DestPath%
SET DestPath=



Canada DBA
Go to Top of Page
   

- Advertisement -