WinXP Disk Defragmenter Run By Task Manager

  • Thread starter Thread starter Jamess B. Holladay
  • Start date Start date
J

Jamess B. Holladay

I am not able to sort how to set WinXPs native Disk Defragmenter to run
automatically with Task Manger. I can get third party Disk Defragmenters to
run i.e. Norton Speed disk but not WinXps. Apparently I have not be
successful in locating the exe required to start the program in TM.
Any help would be appreciated.
 
C:\WINDOWS\SYSTEM32\DEFRAG.EXE The GUI version will not run without user intervention, so use the command line version.

DEFRAG.EXE /? will get you the command line options.
 
Appreciate the advice.

C:\WINDOWS\SYSTEM32\DEFRAG.EXE The GUI version will not run without user
intervention, so use the command line version.

DEFRAG.EXE /? will get you the command line options.
 
Using Doug Knox's advice I think I got it to work with the following path:
C:\WINDOWS\system32\defrag.exe c: /f
Again,thanks Doug>
 
Doug,
When Disk Defragmenter runs it finishes with a "Last Results of 0x0" I can't
locate a explanation of this code. What does it mean or signify about the
out come of the defrag?

James

C:\WINDOWS\SYSTEM32\DEFRAG.EXE The GUI version will not run without user
intervention, so use the command line version.

DEFRAG.EXE /? will get you the command line options.
 
There is no standard but 99.9% of the time means no error. Norton's Speed Disk once used 42 to mean Success. But idiocy like this is rare.
 
I just ran defrag under an error condition and it also returned 0. It is what will be returned if the program doesn't use exit codes.
 
David,
Thanks, for your input.


"David Candy" <.> wrote in message
I just ran defrag under an error condition and it also returned 0. It is
what will be returned if the program doesn't use exit codes.

--
----------------------------------------------------------------------------
----------------------
How to lose a war in Iraq
http://webdiary.com.au/cms/?q=node/1335#comment-48641
=================================================
"David Candy" <.> wrote in message
There is no standard but 99.9% of the time means no error. Norton's Speed
Disk once used 42 to mean Success. But idiocy like this is rare.

--
 
Thanks for the followup, David.

--
Doug Knox, MS-MVP Windows Media Center\Windows Powered Smart Display\Security
Win 95/98/Me/XP Tweaks and Fixes
http://www.dougknox.com
--------------------------------
Per user Group Policy Restrictions for XP Home and XP Pro
http://www.dougknox.com/xp/utils/xp_securityconsole.htm
--------------------------------
Please reply only to the newsgroup so all may benefit.
Unsolicited e-mail is not answered.

"David Candy" <.> wrote in message I just ran defrag under an error condition and it also returned 0. It is what will be returned if the program doesn't use exit codes.
 
What are exit codes and how do you establish them to get more complete and
understandable readings?


"David Candy" <.> wrote in message
I just ran defrag under an error condition and it also returned 0. It is
what will be returned if the program doesn't use exit codes.

--
----------------------------------------------------------------------------
----------------------
How to lose a war in Iraq
http://webdiary.com.au/cms/?q=node/1335#comment-48641
=================================================
"David Candy" <.> wrote in message
There is no standard but 99.9% of the time means no error. Norton's Speed
Disk once used 42 to mean Success. But idiocy like this is rare.

--
 
Exit codes are "results" codes that are returned to the OS by an application. They're generally a number. This number can often be tracked back to the descriptive text of the error, if you know where to look.

For Defrag, the exit codes are:

0 = Completed normally
1 = Cancelled Manually
2 = Command line error
3 = Unknown error
4 = Insufficient memory resources
5 = (Not currently used)
6 = Possible permissions issue (not an Administrator) or a required DLL could not be loaded.
7 = Insufficient Free Space to defrag.

For example, Return = WshShell.Run("defrag " & d & " -f", 1, TRUE), run in a VB Script will launch DEFRAG for the drive letter that is assigned to the variable "d". The TRUE statement tells it to wait for the exit code before continuing on. Return would represent the 0 thru 7 exit code from DEFRAG.

To see this in action, you can download a script that will defrag all fixed disks and generate a log file of the activity.

http://www.dougknox.com/utility/scripts_desc/defrag_all.htm

Download defrag_all2.vbs. VBS scripts can be opened and viewed in Notepad.
 
So --- I have chkdsk as a scheduled task. It just ran for the first time
over the weekend (thanks only to the help of David Candy and others here
who got me straightened out on passwords, but I digress). The scheduled
task window indicates that it did indeed run. There is nothing in the
status column to indicate it ran successfully. And in the last result
column, there is "0x2". Which means what? It ran successfully and then
got crossed up by a command line error?

Craig
 
Doug,
Thanks for the code explanations. I will copy and save along with all the
other good stuff this string generated.
James

Exit codes are "results" codes that are returned to the OS by an
application. They're generally a number. This number can often be tracked
back to the descriptive text of the error, if you know where to look.

For Defrag, the exit codes are:

0 = Completed normally
1 = Cancelled Manually
2 = Command line error
3 = Unknown error
4 = Insufficient memory resources
5 = (Not currently used)
6 = Possible permissions issue (not an Administrator) or a required DLL
could not be loaded.
7 = Insufficient Free Space to defrag.

For example, Return = WshShell.Run("defrag " & d & " -f", 1, TRUE), run in a
VB Script will launch DEFRAG for the drive letter that is assigned to the
variable "d". The TRUE statement tells it to wait for the exit code before
continuing on. Return would represent the 0 thru 7 exit code from DEFRAG.

To see this in action, you can download a script that will defrag all fixed
disks and generate a log file of the activity.

http://www.dougknox.com/utility/scripts_desc/defrag_all.htm

Download defrag_all2.vbs. VBS scripts can be opened and viewed in Notepad.

--
Doug Knox, MS-MVP Windows Media Center\Windows Powered Smart
Display\Security
Win 95/98/Me/XP Tweaks and Fixes
http://www.dougknox.com
 
Craig,

Download the script that I pointed to, and point the scheduled task to run it instead of Defrag. The log file will tell you the results.
 
Back
Top