Article ID: 294743 - Last Review: January 15, 2006 - Revision: 1.3 How to provide event logging for the Disk Defragmenter utility with Windows Script HostThis article was previously published under Q294743 SUMMARY
This article discusses how to provide event logging for the Disk Defragmenter (Defrag.exe) utility with Windows Script Host. This command-line Disk Defragmenter utility that is included with Microsoft Windows XP enables administrators and power users to schedule, and, if needed, to script their operations.
MORE INFORMATION
This command-line version of the Disk Defragmenter utility is unable to log information about its operations to the Windows Event log. However, this utility (similar to most console or command-line interface utilities) provides a description of error levels after it has run. If you use these error levels in combination with the Windows Script Host, you can easily generate or log events that this utility may encounter during its operation.
There are a number of ways to obtain, interpret, and view the data that is specific to the utility status information. You can use the ERRORLEVEL value to select a specified path in a Microsoft Visual Basic script. The Disk Defragmenter utility has the native ability to provide specific "exit code" information to the operating system. The following internal information is related to the Disk Defragmenter utility error levels: Collapse this table
A script can be written to easily monitor and run aspects of the Visual Basic script, based on the ERRORLEVEL value when the utility has completed. NOTE: Your use of the code provided in this article is at your own risk. Microsoft provides this code "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose. An example of how to provide event logging for the Disk Defragmenter utility with Windows Script Host is: 57658
(http://support.microsoft.com/kb/57658/EN-US/
)
Setting the MS-DOS Errorlevel in a Program
188135
(http://support.microsoft.com/kb/188135/EN-US/
)
Description of Windows Script Host (WSH)
278411
(http://support.microsoft.com/kb/278411/EN-US/
)
How to Redirect Command-Line Output
| Article Translations
|

Back to the top
