1 out of 2 rated this helpful - Rate this topic

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 codeDescription
0

Success

1

Access Denied

2

Not Supported

3

Volume Dirty Bit Is Set

4

Not Enough Free Space

5

Corrupt Master File Table Detected

6

Call Canceled

7

Call Cancellation Request Too Late

8

Defrag Engine Is Already Running

9

Unable To Connect To Defrag Engine

10

Defrag Engine Error

11

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

Vds.mof

DLL

Vdswmi.dll

See also

Win32_Volume

 

 

Send comments about this topic to Microsoft

Build date: 11/19/2012

Community Additions

ADD
© 2013 Microsoft. All rights reserved.