Scheduled Task - defrag.exe

  • Thread starter Thread starter Mick
  • Start date Start date
M

Mick

I'm using schtasks.exe in a batch file to create a scheduled task to run
defrag.exe. I can't find the switch that enables the "Stop the task if the
computer ceases to be idle" check box. Is there one?
 
To find out, run defrag.exe /?

Or search Google with this search term: defrag.exe command line switches
 
Leonard Grey said:
To find out, run defrag.exe /?

Or search Google with this search term: defrag.exe command line switches

I already tried that for the OP, couldn't see anything immediately (well, I
searched for "hidden switches" since the "/?" gave no indication of an "only
when idle" option). So I left the replying to more informative people...

Further delving shows that "-i" does the job *in Vista* - but trying it in
XP results in "command line parameter not recognised". Which suggests to me
that there isn't such a switch for XP (because it would probably (key word)
have kept the same switch in Vista).

Have a look at TweakUI - General tab, "Optimize hard disk when idle". The
description says, "...allows Windows to rearrange files on the hard disk
when the computer is not in use to improve performance..."

This apparently does the same as this registry change (usual caveats apply
with regediting):

In

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\OptimalLayout

create a DWORD for "EnableAutoLayout", if needed, and set to:

00000001 for defrag when idle
00000000 for no defrag when idle.

This might do the trick, although tinkering with the Indexing service might
also be needed.

There seem to have been reports that this "optimizing" never seems to finish
(judging by HDD activity), no matter how long the machine is left idle for.
 
Back
Top