Defrag, scheduled task

T

Tom Brown

I am trying to schedule a weekly task to do a Defrag. Apparently this is
more difficult than I thought it would be.

From Kellys-Korner, I copied the routine (below) from Doug Knox.

But, I did as it said and scheduled the MyDefrag.vbs to run two minutes
later. I have seen no evidence that it is running in the Task Manager.

I also went to the Microsoft Windows XP Resource Kit and they talk about two
ways to run it, either with the defragmenter snap-in (dfrg.msc) or
defrag.exe from the command line. They don't mention anything about a
scheduled task.

Any clues or help?

Tom

================================================
Add a Scheduled Task:

Start/Programs/Accessories/System Tools/Scheduled Tasks/Add Scheduled Task

Add Defrag to the Context Menu (Right Click)
http://www2.cajun.net/~theriots/blk/xp_tweaks.htm.
Tip: Copy and paste the following lines into a Notepad file and save it
with a VBS extension. Create your scheduled task to run the VBS file you
just saved. This will need an Adminstrator level account user name and
password for the task.

Set WshShell = WScript.CreateObject("WScript.Shell")

Dim fso, d, dc
Set fso = CreateObject("Scripting.FileSystemObject")
Set dc = fso.Drives
For Each d in dc
If d.DriveType = 2 Then
Return = WshShell.Run("defrag " & d, 1, TRUE)
End If
Next

Set WshShell = Nothing

Doug Knox [MS-MVP]
 
R

Rick \Nutcase\ Rogers

Hi,

Check the conditions of your task, if it is set to only execute when the
system is idle for a predetermined time, then it won't run.

--
Best of Luck,

Rick Rogers, aka "Nutcase" - Microsoft MVP

Associate Expert - WindowsXP Expert Zone

Windows help - www.rickrogers.org
 
J

Jon

The script looks ok and the instructions are valid, so perhaps the problem
is in your setting up a scheduled task, or the script correctly. Perhaps try
scheduling another program for 2 minutes later, such as notepad, and see if
that works ok.

NB If you have included the "Doug Knox [MS-MVP]" line in your script, as it
stands, then pop an apostrophe at the beginning of the line. Otherwise the
program will think it is a line of code.


Jon
 
W

Wesley Vogel

How to Automate Disk Defragmenter Using Task Scheduler Tool in Windows XP
http://support.microsoft.com/default.aspx?scid=kb;en-us;555098

There are two defrag tools in XP.

dfrg.msc is the pretty one that opens from
Start\All Programs\Accessories\System Tools.

defrag.exe is the command line tool that runs from the command prompt.

defrag.exe is the one that you can schedule.

How To Schedule Tasks in Windows XP
http://support.microsoft.com/default.aspx?scid=kb;en-us;308569

--
Hope this helps. Let us know.

Wes
MS-MVP Windows Shell/User

In
 
T

Tom Brown

Thanks Wes,

I am curious how this one compares to the .vbs script that I originally
tried. I don't see either defrag.exe or dfrg.msc in that .vbs script.

Thanks,

Tom


Wesley Vogel said:
How to Automate Disk Defragmenter Using Task Scheduler Tool in Windows XP
http://support.microsoft.com/default.aspx?scid=kb;en-us;555098

There are two defrag tools in XP.

dfrg.msc is the pretty one that opens from
Start\All Programs\Accessories\System Tools.

defrag.exe is the command line tool that runs from the command prompt.

defrag.exe is the one that you can schedule.

How To Schedule Tasks in Windows XP
http://support.microsoft.com/default.aspx?scid=kb;en-us;308569

--
Hope this helps. Let us know.

Wes
MS-MVP Windows Shell/User

In
Tom Brown said:
I am trying to schedule a weekly task to do a Defrag. Apparently this is
more difficult than I thought it would be.

From Kellys-Korner, I copied the routine (below) from Doug Knox.

But, I did as it said and scheduled the MyDefrag.vbs to run two minutes
later. I have seen no evidence that it is running in the Task Manager.

I also went to the Microsoft Windows XP Resource Kit and they talk about
two ways to run it, either with the defragmenter snap-in (dfrg.msc) or
defrag.exe from the command line. They don't mention anything about a
scheduled task.

Any clues or help?

Tom

================================================
Add a Scheduled Task:

Start/Programs/Accessories/System Tools/Scheduled Tasks/Add Scheduled
Task

Add Defrag to the Context Menu (Right Click)
http://www2.cajun.net/~theriots/blk/xp_tweaks.htm.
Tip: Copy and paste the following lines into a Notepad file and save it
with a VBS extension. Create your scheduled task to run the VBS file you
just saved. This will need an Adminstrator level account user name and
password for the task.

Set WshShell = WScript.CreateObject("WScript.Shell")

Dim fso, d, dc
Set fso = CreateObject("Scripting.FileSystemObject")
Set dc = fso.Drives
For Each d in dc
If d.DriveType = 2 Then
Return = WshShell.Run("defrag " & d, 1, TRUE)
End If
Next

Set WshShell = Nothing

Doug Knox [MS-MVP]
 
T

Tom Brown

Thanks Rick.

No, I didn't have any conditions set but I ran it just now and I couldn't
get it to quit.

Thanks again,

Tom


Rick "Nutcase" Rogers said:
Hi,

Check the conditions of your task, if it is set to only execute when the
system is idle for a predetermined time, then it won't run.

--
Best of Luck,

Rick Rogers, aka "Nutcase" - Microsoft MVP

Associate Expert - WindowsXP Expert Zone

Windows help - www.rickrogers.org

Tom Brown said:
I am trying to schedule a weekly task to do a Defrag. Apparently this is
more difficult than I thought it would be.

From Kellys-Korner, I copied the routine (below) from Doug Knox.

But, I did as it said and scheduled the MyDefrag.vbs to run two minutes
later. I have seen no evidence that it is running in the Task Manager.

I also went to the Microsoft Windows XP Resource Kit and they talk about
two ways to run it, either with the defragmenter snap-in (dfrg.msc) or
defrag.exe from the command line. They don't mention anything about a
scheduled task.

Any clues or help?

Tom

================================================
Add a Scheduled Task:

Start/Programs/Accessories/System Tools/Scheduled Tasks/Add Scheduled
Task

Add Defrag to the Context Menu (Right Click)
http://www2.cajun.net/~theriots/blk/xp_tweaks.htm.
Tip: Copy and paste the following lines into a Notepad file and save it
with a VBS extension. Create your scheduled task to run the VBS file you
just saved. This will need an Adminstrator level account user name and
password for the task.

Set WshShell = WScript.CreateObject("WScript.Shell")

Dim fso, d, dc
Set fso = CreateObject("Scripting.FileSystemObject")
Set dc = fso.Drives
For Each d in dc
If d.DriveType = 2 Then
Return = WshShell.Run("defrag " & d, 1, TRUE)
End If
Next

Set WshShell = Nothing

Doug Knox [MS-MVP]
 
T

Tom Brown

Thanks Jon,

That's a good idea about setting the notepad to run just for troubleshooting
purposes.

No, I left out Doug's name although I should put it back in with the
apostrophe to make sure he gets credit in case anyone ever looks at it.

Thanks,

Tom

Jon said:
The script looks ok and the instructions are valid, so perhaps the problem
is in your setting up a scheduled task, or the script correctly. Perhaps
try scheduling another program for 2 minutes later, such as notepad, and
see if that works ok.

NB If you have included the "Doug Knox [MS-MVP]" line in your script, as
it stands, then pop an apostrophe at the beginning of the line. Otherwise
the program will think it is a line of code.


Jon


Tom Brown said:
I am trying to schedule a weekly task to do a Defrag. Apparently this is
more difficult than I thought it would be.

From Kellys-Korner, I copied the routine (below) from Doug Knox.

But, I did as it said and scheduled the MyDefrag.vbs to run two minutes
later. I have seen no evidence that it is running in the Task Manager.

I also went to the Microsoft Windows XP Resource Kit and they talk about
two ways to run it, either with the defragmenter snap-in (dfrg.msc) or
defrag.exe from the command line. They don't mention anything about a
scheduled task.

Any clues or help?

Tom

================================================
Add a Scheduled Task:

Start/Programs/Accessories/System Tools/Scheduled Tasks/Add Scheduled
Task

Add Defrag to the Context Menu (Right Click)
http://www2.cajun.net/~theriots/blk/xp_tweaks.htm.
Tip: Copy and paste the following lines into a Notepad file and save it
with a VBS extension. Create your scheduled task to run the VBS file you
just saved. This will need an Adminstrator level account user name and
password for the task.

Set WshShell = WScript.CreateObject("WScript.Shell")

Dim fso, d, dc
Set fso = CreateObject("Scripting.FileSystemObject")
Set dc = fso.Drives
For Each d in dc
If d.DriveType = 2 Then
Return = WshShell.Run("defrag " & d, 1, TRUE)
End If
Next

Set WshShell = Nothing

Doug Knox [MS-MVP]
 
T

Tom Brown

Ahhh, I guess the line with "Return = WshShell.Run("defrag " & d, 1, TRUE)"
covers that.

Tom

Tom Brown said:
Thanks Wes,

I am curious how this one compares to the .vbs script that I originally
tried. I don't see either defrag.exe or dfrg.msc in that .vbs script.

Thanks,

Tom


Wesley Vogel said:
How to Automate Disk Defragmenter Using Task Scheduler Tool in Windows XP
http://support.microsoft.com/default.aspx?scid=kb;en-us;555098

There are two defrag tools in XP.

dfrg.msc is the pretty one that opens from
Start\All Programs\Accessories\System Tools.

defrag.exe is the command line tool that runs from the command prompt.

defrag.exe is the one that you can schedule.

How To Schedule Tasks in Windows XP
http://support.microsoft.com/default.aspx?scid=kb;en-us;308569

--
Hope this helps. Let us know.

Wes
MS-MVP Windows Shell/User

In
Tom Brown said:
I am trying to schedule a weekly task to do a Defrag. Apparently this
is
more difficult than I thought it would be.

From Kellys-Korner, I copied the routine (below) from Doug Knox.

But, I did as it said and scheduled the MyDefrag.vbs to run two minutes
later. I have seen no evidence that it is running in the Task Manager.

I also went to the Microsoft Windows XP Resource Kit and they talk about
two ways to run it, either with the defragmenter snap-in (dfrg.msc) or
defrag.exe from the command line. They don't mention anything about a
scheduled task.

Any clues or help?

Tom

================================================
Add a Scheduled Task:

Start/Programs/Accessories/System Tools/Scheduled Tasks/Add Scheduled
Task

Add Defrag to the Context Menu (Right Click)
http://www2.cajun.net/~theriots/blk/xp_tweaks.htm.
Tip: Copy and paste the following lines into a Notepad file and save it
with a VBS extension. Create your scheduled task to run the VBS file you
just saved. This will need an Adminstrator level account user name and
password for the task.

Set WshShell = WScript.CreateObject("WScript.Shell")

Dim fso, d, dc
Set fso = CreateObject("Scripting.FileSystemObject")
Set dc = fso.Drives
For Each d in dc
If d.DriveType = 2 Then
Return = WshShell.Run("defrag " & d, 1, TRUE)
End If
Next

Set WshShell = Nothing

Doug Knox [MS-MVP]
 
W

Wesley Vogel

That line is from Doug Knox's defrag_all.vbs or defrag_all2.vbs

Defragment All Hard Drives
http://www.dougknox.com/utility/scripts_desc/defrag_all.htm

--
Hope this helps. Let us know.

Wes
MS-MVP Windows Shell/User

In
Tom Brown said:
Ahhh, I guess the line with "Return = WshShell.Run("defrag " & d, 1,
TRUE)" covers that.

Tom

Tom Brown said:
Thanks Wes,

I am curious how this one compares to the .vbs script that I originally
tried. I don't see either defrag.exe or dfrg.msc in that .vbs script.

Thanks,

Tom


Wesley Vogel said:
How to Automate Disk Defragmenter Using Task Scheduler Tool in Windows
XP http://support.microsoft.com/default.aspx?scid=kb;en-us;555098

There are two defrag tools in XP.

dfrg.msc is the pretty one that opens from
Start\All Programs\Accessories\System Tools.

defrag.exe is the command line tool that runs from the command prompt.

defrag.exe is the one that you can schedule.

How To Schedule Tasks in Windows XP
http://support.microsoft.com/default.aspx?scid=kb;en-us;308569

--
Hope this helps. Let us know.

Wes
MS-MVP Windows Shell/User

In Tom Brown <[email protected]> hunted and pecked:
I am trying to schedule a weekly task to do a Defrag. Apparently this
is
more difficult than I thought it would be.

From Kellys-Korner, I copied the routine (below) from Doug Knox.

But, I did as it said and scheduled the MyDefrag.vbs to run two minutes
later. I have seen no evidence that it is running in the Task Manager.

I also went to the Microsoft Windows XP Resource Kit and they talk
about two ways to run it, either with the defragmenter snap-in
(dfrg.msc) or defrag.exe from the command line. They don't mention
anything about a scheduled task.

Any clues or help?

Tom

================================================
Add a Scheduled Task:

Start/Programs/Accessories/System Tools/Scheduled Tasks/Add Scheduled
Task

Add Defrag to the Context Menu (Right Click)
http://www2.cajun.net/~theriots/blk/xp_tweaks.htm.
Tip: Copy and paste the following lines into a Notepad file and save
it with a VBS extension. Create your scheduled task to run the VBS
file you just saved. This will need an Adminstrator level account user
name and password for the task.

Set WshShell = WScript.CreateObject("WScript.Shell")

Dim fso, d, dc
Set fso = CreateObject("Scripting.FileSystemObject")
Set dc = fso.Drives
For Each d in dc
If d.DriveType = 2 Then
Return = WshShell.Run("defrag " & d, 1, TRUE)
End If
Next

Set WshShell = Nothing

Doug Knox [MS-MVP]
 
W

Wesley Vogel

Tom,

If nothing else, follow the instructions for scheduling and substitute
defrag_all.vbs or defrag_all2.vbs.

--
Hope this helps. Let us know.

Wes
MS-MVP Windows Shell/User

In
Tom Brown said:
Thanks Wes,

I am curious how this one compares to the .vbs script that I originally
tried. I don't see either defrag.exe or dfrg.msc in that .vbs script.

Thanks,

Tom


Wesley Vogel said:
How to Automate Disk Defragmenter Using Task Scheduler Tool in Windows XP
http://support.microsoft.com/default.aspx?scid=kb;en-us;555098

There are two defrag tools in XP.

dfrg.msc is the pretty one that opens from
Start\All Programs\Accessories\System Tools.

defrag.exe is the command line tool that runs from the command prompt.

defrag.exe is the one that you can schedule.

How To Schedule Tasks in Windows XP
http://support.microsoft.com/default.aspx?scid=kb;en-us;308569

--
Hope this helps. Let us know.

Wes
MS-MVP Windows Shell/User

In
Tom Brown said:
I am trying to schedule a weekly task to do a Defrag. Apparently this
is more difficult than I thought it would be.

From Kellys-Korner, I copied the routine (below) from Doug Knox.

But, I did as it said and scheduled the MyDefrag.vbs to run two minutes
later. I have seen no evidence that it is running in the Task Manager.

I also went to the Microsoft Windows XP Resource Kit and they talk about
two ways to run it, either with the defragmenter snap-in (dfrg.msc) or
defrag.exe from the command line. They don't mention anything about a
scheduled task.

Any clues or help?

Tom

================================================
Add a Scheduled Task:

Start/Programs/Accessories/System Tools/Scheduled Tasks/Add Scheduled
Task

Add Defrag to the Context Menu (Right Click)
http://www2.cajun.net/~theriots/blk/xp_tweaks.htm.
Tip: Copy and paste the following lines into a Notepad file and save it
with a VBS extension. Create your scheduled task to run the VBS file you
just saved. This will need an Adminstrator level account user name and
password for the task.

Set WshShell = WScript.CreateObject("WScript.Shell")

Dim fso, d, dc
Set fso = CreateObject("Scripting.FileSystemObject")
Set dc = fso.Drives
For Each d in dc
If d.DriveType = 2 Then
Return = WshShell.Run("defrag " & d, 1, TRUE)
End If
Next

Set WshShell = Nothing

Doug Knox [MS-MVP]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top