March 06, 2000 05:06 PM

Scheduling Windows 2000’s Disk Defragmenter

Rating: (0)
Windows IT Pro
InstantDoc ID #8276
Contrary to what you might have heard, NTFS partitions in Windows 2000 (Win2K) and Windows NT do fragment over time. The system doesn't write files in contiguous areas on the hard disk. The larger the volume size, the more fragmented your hard disk is likely to become. As a result, it takes longer for the OS to access files and folders because it must perform extra disk reads to collect all the pieces. Even creating new files takes longer because the OS must locate free space scattered across the volume.

ARTICLE TOOLS

You must be a paid Professional Member to access this entire article.

Already a Professional Member? Please log in now:

NOT A PROFESSIONAL MEMBER? YOU CHOOSE:

Monthly or Annual

Professional Membership

VIP Membership

Compare Member Benefits

Add a Comment

the server piece is on c:\\. on d:\\ only some tools for administration. on e:\\ all apps and services for users

Anonymous User 7/27/2005 2:55:04 AM


You said you paste your code under the service piece. what is the service piece?

Anonymous User 6/16/2005 5:30:15 PM


the script runs great. only i have 2 servers whith a unmounted partition. the script run first the unmounted drive (fat). then the first drive (ntfs) marked as c: then the last drive (ntfs) marked as e:. so i mis the d: drive also NTFS. Please the code to check this drive is not NFTS and quick select the first NTFS.
The fat-drive is as first drive on the list.

Anonymous User 6/14/2005 7:35:21 AM


Great script. Thanks a lot

Anonymous User 4/20/2005 3:42:29 PM


Something that is seems to continually be overlooked is that using task schedular you can only run interactive i.e. you must be logged on. This wont work for any true IT enviorment. My fix is this:
I used a program called DIRMS (http://www.dirms.com/) and a light weight programming language called Winbatch. You can use VB or C+ as well. I pasted the code below for the service piece.

********************
time_current=TimeYmdHms ( )
cur_tm4=ItemExtract(4, time_current, ":")
if cur_tm4 != 00
add= 24 - cur_tm4
time_wait=TimeAdd(time_current,"0000:00:00:%add%:00:00")
TimeWait(time_wait)
RunHideWait("c:\\Program Files\\Dirms\\dirms.exe","c -q")
else
RunHideWait("c:\\Program Files\\Dirms\\dirms.exe","c -q")
endif
**************************

once you have something similar in the langauge of your choice compile it to an ".exe" file.

Then use something like "srvany" (instructions here: http://support.microsoft.com/default.aspx?scid=kb;en-us;137890)
to install the exe as a service then the defrag can happen at any time you choose and in the background whether your logged on or not.


Anonymous User 3/4/2005 6:18:30 PM


Surprising..... hasnt any of u ever heard of contig.exe from www.sysinternals.com ! Can be scheduled, scripted, whatever....

Anonymous User 1/12/2005 4:23:39 PM


Very useful!!

Was looking for an answer to whether Defrag can be scheduled. A: NO

But provided me with a solution instantly as well!
Thanks a lot, exactly what I was looking for!!

Cheers, Jammyme
:D :D :D :D :D :D

Anonymous User 1/6/2005 6:42:22 AM


Almost forgot... use sysinternals pskill.exe to kill the processes. Create a bat file and dump it in the system32 directory along with pskill.exe. The bat file should look something like:

pskill.exe autodefrag.exe
pskill.exe mmc.exe
pskill.exe dfrgntfs.exe

Anonymous User 12/15/2004 2:53:01 PM


Make it easy. For those that are in corps that do NOT like .vbs run in the servers, create a schedule for AutoDefrag.exe to run a specified time, then create a second schedule to kill autodefrag.exe, mmc.exe and dfrgntfs.exe. This allows you to schedule a start and stop time without any hitches. Cheers...

Anonymous User 12/15/2004 2:49:28 PM


I also need this to run when the screen is autolocked. Any ideas?

I found this article which possibly gives some insight into detecting if the pc is locked by checking if the screensaver is running...

http://www.microsoft.com/technet/scriptcenter/resources/qanda/nov04/hey1115.mspx

Anonymous User 11/22/2004 3:57:35 PM


You must log on before posting a comment.

Are you a new visitor? Register Here
Free Power Tools Brochure
Get Mark Minasi's 17-page guide today!



      

advertisement

GOOGLE LINKS
SPONSORED LINKS
FEATURED LINKS

White Papers

Your remote offices contain valuable electronic data – are they adequately protected? Learn how proven technologies can reliably and cost-effectively back up a branch office from a central location, in real time, to disk or tape, and even utilize existing backup solutions.

Downloads

PacketTrap IT is a comprehensive and affordable network management and application monitoring solution that solves problems associated with bandwidth, network and application performance, and connectivity. Gain insight into your network - try PacketTrapIT free for 21 days!

Web Seminars

IT administrators have to solve a myriad of problems. This web seminar outlines the ten most common systems management pains - including managing highly distributed systems and dealing with data theft/loss – and the best practices to address each.

eLearning Series

We bring the experts direct to you to share their real-world perspective and expertise. During each event, three sessions stream in real time, so you can learn, ask questions, and get solutions.
Upcoming event: Getting the Most with Exchange 2010 with Paul Robichaux

Subscribe to Windows IT Pro!

Windows is a trademark of the Microsoft group of companies. Windows IT Pro is used by Penton Media Inc. under license from owner.