Why the "create restore point" script work differently on Windows 7 and on Windows 10/8.1

0

1

From a how-to-geek article, I get a script like this:

strDesc = "Restore Point by script"
Set oArgs = WScript.Arguments
If oArgs.Count > 0 Then strDesc = oArgs(0)

WScript.Echo "Creating Restore Point: " & strDesc

Set oRestorePoint = GetObject("winmgmts:\\.\root\default:SystemRestore")
strResult = oRestorePoint.CreateRestorePoint(strDesc, 0, 100)

If strResult <> 0 Then
    WScript.Echo "Error " & strResult & ": Unable to create Restore Point"
    WScript.Sleep 444000    'Let user see the result
Else
    WScript.Echo "Restore Point created successfully."
    WScript.Sleep 2000      'Let user see the result
End If

WScript.Quit strResult

I create a scheduled task with this script on Windows 7 to have it create restore point for me daily, and it works well.

However on Windows 8.1/10, I find a strange behavior. Inside a Administrator CMD, executing

cscript CreateRestorePoint.vbs

does not create a new restore point when any restore point has existed(but it still prints "Restore Point created successfully"). In other word, cscript CreateRestorePoint.vbs creates a restore point only after I do vssadmin delete shadows /all, but a second run of cscript CreateRestorePoint.vbs fails due to the existing of first restore point. -- This problem does not happen on Windows 7 SP1.

Can someone explain and fix this problem on Windows 8.1/10 ?

[[[ UPDATE: Problem Solved ]]]

Just as Ken points out in his comment, adding a registry key [HKLM\Software\Microsoft\Windows NT\CurrentVersion\SystemRestore] SystemRestorePointCreationFrequency=10 is the solution(reboot required) . Since Windows 8, Microsoft defaultly allows create only one restore point every 24 hours. SystemRestorePointCreationFrequency=10 decrease that limit to 10 miniutes. See this MSDN page.

Jimm Chen

Posted 2015-11-02T07:11:17.030

Reputation: 4 129

Try "winmgmts:{impersonationLevel=impersonate}!root/default:SystemRestore" (taken from this article).

– harrymc – 2015-11-06T08:52:49.133

Answers

2

It is much easier to use power shell for Windows 8.1 and 10. They both have it and you create a one liner and name it .

One note.. you can only run the Checkpoint once every 24 hours.

Place this line in notepad and save the file as CreateCheckpoint.ps1 (make sure that the file is not saved as CreateCheckpoint.ps1.txt).

Checkpoint-Computer -Description "Daily Restore Point"

Goto an administrator command prompt and type powershell. A window will pop open. Just go to the path of the file and type ./createcheckpoint.ps1 and it will create the restore point.

If this works it will show the restore point in your list. If you want to put this in a scheduled task, create a run.bat file and place these lines in it. Change the path below to where you placed the ps1 file. You need to run the bat file as administrator.

@ECHO OFF
PowerShell.exe -command "& c:\restorepoint.ps1 -description 'DailyRP'"
PAUSE

NobleMan

Posted 2015-11-02T07:11:17.030

Reputation: 476

Thank you. I need some time to try Powershell out. Did you mean my .vbs fails because of "create only once every 24 hour" limit? Any Microsoft official statement about this? Any way to break this limit? – Jimm Chen – 2015-11-06T04:06:56.773

No such limit - only that Windows will create a restore point automatically if one was not created within the last 24 hours. Minimum rather than maximum. See my comment on the post. – harrymc – 2015-11-06T08:54:39.703

2WARNING: A new system restore point cannot be created because one has already been created within the past 1440 minutes. The frequency of restore point creation can be changed by creating the DWORD value 'SystemRestorePointCreationFrequency' under the registry key 'HKLM\Software\Microsoft\Windows NT\CurrentVersion\SystemRestore'. The value of this registry key indicates the necessary time interval (in minutes) between two restore point creation. The default value is 1440 minutes (24 hours). – NobleMan – 2015-11-06T13:19:37.307

That is if you want to script it and not use the manually way of running it. – NobleMan – 2015-11-06T13:20:17.067

That's a limitation of Checkpoint-Computer alone. – harrymc – 2015-11-09T06:49:06.887

@JimmChen , I am glad you got this situation resolved. Thanks for the Bounty! – NobleMan – 2016-01-18T15:50:05.263

This command will change that value to 0 minutes which will allow you to create a restore point. Then you can change the value back to 1440 to return it to the default.
$registryPath = "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SystemRestore"
IF(!(Test-Path $registryPath)) {New-Item -Path $registryPath -Force | Out-Null} Get-Item -Path $registryPath | New-ItemProperty -Name "SystemRestorePointCreationFrequency" -Value "0" -PropertyType DWord -Force | Out-Null
– kb4000 – 2018-09-12T00:10:24.403