Defrag method of the Win32_Volume class
The Defrag method defragments the volume.
This topic uses Managed Object Format (MOF) syntax. For more information about using this method, see Calling a Method. The Defrag method, like the Format method, can run for a very long time. These methods are normally called asynchronously. If your code cancels the call by calling IWbemServices::CancelAsyncCall (or SWbemSink.Cancel in script or Visual Basic), then the provider is not notified and the operation continues to completion. During this time, no other disk defragmentation operations can be performed, because only one instance of a defragmentation engine can run at a time.
Syntax
uint32 Defrag( [in] boolean Force, [out] object DefragAnalysis );
Parameters
- Force [in]
-
If true, forces defragmenting of the volume even if free space is low. The default is false.
- DefragAnalysis [out]
-
A Win32_DefragAnalysis object that contains the properties that describe the extent to which the volume is fragmented.
Return value
| Return code | Description |
|---|---|
|
Success |
|
Access Denied |
|
Not Supported |
|
Volume Dirty Bit Is Set |
|
Not Enough Free Space |
|
Corrupt Master File Table Detected |
|
Call Canceled |
|
Call Cancellation Request Too Late |
|
Defrag Engine Is Already Running |
|
Unable To Connect To Defrag Engine |
|
Defrag Engine Error |
|
Unknown Error |
Examples
For script code examples, see WMI Tasks for Scripts and Applications and the TechNet ScriptCenter Script Repository.
For C++ code examples, see WMI C++ Application Examples.
Requirements
|
Minimum supported client | None supported [desktop apps only] |
|---|---|
|
Minimum supported server | Windows Server 2003 [desktop apps only] |
|
Namespace |
\root\CIMV2 |
|
MOF |
|
|
DLL |
|
See also
Send comments about this topic to Microsoft
Build date: 11/19/2012
