Enable method of the SystemRestore class

Enables monitoring on a particular drive.

Syntax

uint32 Enable(
  [in] String Drive
);

Parameters

Drive [in]

The drive to be enabled. The drive string should be of the form "C:\". If this parameter is the system drive or an empty string (""), all drives are monitored.

Return value

If the method succeeds, the return value is S_OK. Otherwise, the method returns one of the COM error codes defined in WinError.h.

Remarks

The Enable method does not wait for monitoring to be enabled completely before it returns, because this could take a while. Instead, it returns immediately after starting the System Restore service and filter driver.

To enable System Restore on a non-system drive, you must first enable System Restore on the system drive.

This method fails in safe mode.

Examples

'Enable Method of the SystemRestore Class
'Enables monitoring on a particular drive.

Set Args = wscript.Arguments
If Args.Count() > 0 Then
    Drive = Args.item(0)
Else 
    Drive = ""
End If

Set obj = GetObject("winmgmts:{impersonationLevel=impersonate}!root/default:SystemRestore")
If (obj.Enable(Drive)) = 0 Then
    wscript.Echo "Success"
Else 
    wscript.Echo "Failed"
End If

Requirements

Requirement Value
Minimum supported client
Windows XP [desktop apps only]
Minimum supported server
None supported
Namespace
Root\Default
MOF
Sr.mof

See also

SystemRestore