Auto Defrag Methods

23:36 เขียนโดย QA Optimization - Performance and Stability

1. From a Bat File

Defrag in both Windows 9x and XP can be easily run from a batch file which when
clicked will automatically begin
defragging your drive or drives, and exit when done. Here's how.

Windows 95/98/Me

This simple defrag bat file automatically defrags all your local drives.

@echo off
DEFRAG.EXE /ALL /F /P /NOPROMPT
cls

If you've never written a batch file, don't worry, it's a simple. Just open
up a new notepad document, type the commands,
then save the file with a .BAT extension.

Note - make sure you are not hiding file extensions. If you're not sure, go to
Folder Options and make sure
there is no checkmark next to "Hide extensions for known file types"


Notice the switches in the above command line

/ALL - means all drives will be defragmented
/F - means all files and free space will be defragmented.
/NOPROMPT - means to defrag without any user prompts. In other words, defrag
begins automatically without questions.

Other switches you can use include.

/U to defragment files only.

/Q to defragment free space only.

/CONCISE to have only the Hide Details view displayed (this is the default).

/DETAILED to have the Details view displayed.

/P - this one is for the old Windows 95 defrag and means System and hidden
files will be optimized

If it's only one drive you need to defrag, just omit the all switch and enter
the drive letter. i.e.
DEFRAG.EXE C: /F /NOPROMPT

To end the defragging at any time, press Ctrl + C

Windows XP

Windows XP defrag does not have an ALL switch but this can be easily worked
around by simply entering each drive in the
bat file. It's only something you have to do once and then you will have a file
that will defrag all your drives with a click
and exit automatically when done.

Let's assume you have 3 partitions you wish to include, c: d: and e:

Open up notepad, enter the simple commands below, and save the file with a .bat
extension.

defrag c: -f
defrag d: -f
defrag e: -f
Double clicking the file will defrag the drives in the order they are listed in
the file and automatically exit when finished.
The f switch is optional and is used to prevent any prompts that your free
space is low

To end the defrag at any time press Ctrl + C



2. Task Scheduling Defrag

Windows 9x

You can also automate defrag by configuring it in Task Scheduler to run at a
set time schedule. To do that in Windows 9x, double-click
My Computer hen open Scheduled Tasks and double click Add Scheduled Task.
Click Next and Choose Disk Defragmenter.from the
list Choose the time schedule and just follow the wizard. At the end, click
"Open Advanced Properties for this task when I click finish"
and enter your defrag options at the end of the defrag command line.. Example:

C:\WINDOWS\DEFRAG.EXE /ALL /NOPROMPT

to defrag all your drives without prompting.



Windows XP

In Windows XP, you can access Task Scheduler in your Accessories>System Tools
folder or in the Control Panel (Settings>Control Panel>Scheduled Tasks)
However you can't automate the XP defrag by simply choosing the defrag utitlity
as the task to run. This will only open up the XP defragmenter and stay there
waiting for user intervention. However, we can work around this XP oversight by
scheduling a bat file to run the defrag. Just create a bat file as described
earlier in this article.
Then start the Task Scheduler wizard and when you get to the list of program
choices, click the Browse button to find and select your bat file.

3. Customizing the Default Defrag Shortcut

Windows 9x only

You can also enter preferred defrag switches at the end of your Defrag shortcut
command line. Click Start>Programs> Accessories>System Tools
where you will see the Disk Defragmenter entry. Right click it, go to
Properties screen, click the Shortcut tab, then click at the end of the command
line in the Target box, enter the switches you prefer. For example, to have
defrag automatically defrag your c: drive without any prompting, every time you
start it,
you would add C: followed by the noprompt switch
C:\WINDOWS\DEFRAG.EXE C: /NOPROMPT
Choosing Defrag would then begin defragging your c: drive automatically and
exit after it finishes.

4. AutoRun Defrag from the Registry

You can also place a command to start defrag in a run key in your registry.
This key here:
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunServicesOnce
(if the RunServicesOnce key doesn't exist, create it)
Then in the right hand pane create a String value named Defrag.
Double click it and assuming you want all your drives defragged, enter:
DEFRAG.EXE /ALL
What this will do is start defrag on reboot - but only once - as the name
"RunServicesOnce" implies.

The above can also be implemented automatically in Windows 98 by using
Defrag.inf which is included on the Windows 98 CD

0 ความคิดเห็น:

แสดงความคิดเห็น