CreateRestorePoint method of the SystemRestore class

Creates a restore point.

This method is the scriptable equivalent of the SRSetRestorePoint function.

Syntax

uint32 CreateRestorePoint(
  [in] String Description,
  [in] uint32 RestorePointType,
  [in] uint32 EventType
);

Parameters

Description [in]

The description to be displayed so the user can easily identify a restore point. The maximum length of an ANSI string is MAX_DESC. The maximum length of a Unicode string is MAX_DESC_W. For more information, see Restore Point Description Text.

RestorePointType [in]

The type of restore point. This member can be one of the following values.

Restore point type Meaning
APPLICATION_INSTALL
0
An application has been installed.
APPLICATION_UNINSTALL
1
An application has been uninstalled.
DEVICE_DRIVER_INSTALL
10
A device driver has been installed.
MODIFY_SETTINGS
12
An application has had features added or removed.
CANCELLED_OPERATION
13
An application needs to delete the restore point it created. For example, an application would use this flag when a user cancels an installation.

EventType [in]

The type of event. This member can be one of the following values.

Event type Meaning
BEGIN_NESTED_SYSTEM_CHANGE
102
A system change has begun. A subsequent nested call does not create a new restore point.
Subsequent calls must use END_NESTED_SYSTEM_CHANGE, not END_SYSTEM_CHANGE.
BEGIN_SYSTEM_CHANGE
100
A system change has begun.
A subsequent call must use END_SYSTEM_CHANGE, not END_NESTED_SYSTEM_CHANGE.
END_NESTED_SYSTEM_CHANGE
103
A system change has ended.
END_SYSTEM_CHANGE
101
A system change has ended.

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

**Windows 8: **

A new registry key enables application developers to change the frequency of restore-point creation.

Applications should create this key to use it because it will not preexist in the system. The following will apply by default if the key does not exist. If an application calls the CreateRestorePoint method to create a restore point, Windows skips creating this new restore point if any restore points have been created in the last 24 hours. The CreateRestorePoint method returns S_OK.

Developers can write applications that create the DWORD value SystemRestorePointCreationFrequency under the registry key HKLM\Software\Microsoft\Windows NT\CurrentVersion\SystemRestore. The value of this registry key can change the frequency of restore point creation. The value of this registry key can change the frequency of restore point creation.

If the application calls CreateRestorePoint to create a restore point, and the registry key value is 0, system restore does not skip creating the new restore point.

If the application calls CreateRestorePoint to create a restore point, and the registry key value is the integer N, system restore skips creating a new restore point if any restore points were created in the previous N minutes.

Examples

'CreateRestorePoint Method of the SystemRestore Class
'Creates a restore point. Specifies the beginning and 
'the ending of a set of changes so that System Restore 
'can create a restore point.This method is the 
'scriptable equivalent of the SRSetRestorePoint function.

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

Set obj = GetObject("winmgmts:{impersonationLevel=impersonate}!root/default:SystemRestore")

If (obj.CreateRestorePoint(RpName, 0, 100)) = 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