Re: WinXP Disk Defragmenter Run By Task Manager

Tech-Archive recommends: Fix windows errors by optimizing your registry



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 Knox MS-MVP wrote:
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.


.



Relevant Pages

  • Re: Writing Script for ScanDisk and Defrag
    ... the scheduled task how can I get it to actually run them without needing any ... Microsoft PowerShell MVP ... Coming Soon: Windows PowerShell: TFM 2nd Ed. ... to me, however, as defrag is designed to avoid committing changes that ...
    (microsoft.public.scripting.wsh)
  • Re: Disk Clean up and Defrag Windows XP Pro
    ... believe you need an Account with a password to start a scheduled task. ... MS-MVP Windows Shell/User ... Could you provide me the command line you used for the Scheduled Defrag? ... How to Automate Disk Defragmenter Using Task Scheduler Tool in Windows ...
    (microsoft.public.windowsxp.general)
  • Re: Scheduling a Defrag
    ... I use the built-in Windows ... >> defrag utility rather than a third party program. ... > from a standby state. ... scheduled task do the following: ...
    (microsoft.public.windowsxp.general)
  • Re: Sceduled tasks for disk defrag
    ... This can be run as a scheduled task and will defrag all fixed hard disks. ... >> How to Automate Disk Defragmenter Using Task Scheduler Tool in Windows XP ...
    (microsoft.public.windowsxp.basics)
  • Re: Updating programs automatically
    ... If your Share is always connected, just create a Scheduled Task ... > to find out how to create a batch file or login script? ... >>Just download it yourself, ...
    (microsoft.public.windowsxp.general)