Sign in to follow this  
Followers 0
FredAI

System restore UDF

9 posts in this topic

#1 ·  Posted (edited)

Hi.

I needed this for one of my apps, and all I could find here was a WMI object function to create a restore point, so I decided to create this UDF and post it here.

It has functions to enumerate, delete (one or all) and create restore points.

Also enable or disable the system restore, and restore the system to one of the restore points.

There are only two functions available through DllCall on msdn, the others are WMI.

The UDF is not commented yet, I'll do it tomorrow and update. It's getting late, now. Better call it a night.

Sorry for the delay. Here's the commented updated version: (28 downloads before)

Note: Some functions were slightly modified.

Updated 15/11/2011 (66 total downloads). The $DriveL optional parameter in the _SR_Enable and _SR_Disable functions must be in the format $SystemDrive & '\', or the functions won't work.

SystemRestore.au3

Edited by FredAI
1 person likes this

Share this post


Link to post
Share on other sites



Just a simple advice: Be careful when using the _SR_Restore function. It marks the chosen system restore to be performed on reboot, and I couldn't find any documentation on how to cancel it.

Share this post


Link to post
Share on other sites

Thanks, its great :D


An AutoIT user.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Function _SR_RemoveAllRestorePoints() doesn't work in Windows 8.

Edit: Sorry, I did a syntax error. It's working fine.

Edited by ffdshow

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

I tried this syntax _SR_CreateRestorePoint('Test Restore Point') but it doesn't work?

This is snippet of code I tried

#include <SystemRestore.au3>

_SR_CreateRestorePoint('Test Restore Point')

If @error = 0 Then
   MsgBox(0 + 64 + 262144, "Error", "Failed to create System Restore Point!")
Else
   MsgBox(0 + 64 + 262144, "System Message", "System Restore Point created successfully.", 5)
EndIf
Edited by firestrife23

Share this post


Link to post
Share on other sites

Remarks .......: The system restore takes a few seconds to update.

try

#include <SystemRestore.au3>
 
_SR_CreateRestorePoint('Test Restore Point')
 
Sleep(3000)
 

If @error = 0 Then
   MsgBox(0 + 64 + 262144, "Error", "Failed to create System Restore Point!")
Else
   MsgBox(0 + 64 + 262144, "System Message", "System Restore Point created successfully.", 5)
EndIf

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
Share on other sites

MikahS,

Thank you for your suggestion but no luck so far... here's my another attempt, this time it come back as success.... however, when you run rstrui.exe to verify and it's not there as if it never got created in first place....

#include <MsgBoxConstants.au3>
#include <SystemRestore.au3>

CreateRestorePoint()

Func CreateRestorePoint()
   Local $pid = _SR_CreateRestorePoint('Test Restore Point')
   Do
      Sleep(3000)
   Until $pid = 0 or $pid = 1
   If $pid = 0 Then
      MsgBox(0 + 64 + 262144, "Error", "Failed to create System Restore Point!")
   ElseIf $pid = 1 Then
      MsgBox(0 + 64 + 262144, "System Message", "System Restore Point created successfully.", 5)
   EndIf
EndFunc

Share this post


Link to post
Share on other sites

 

MikahS,

Thank you for your suggestion but no luck so far... here's my another attempt, this time it come back as success.... however, when you run rstrui.exe to verify and it's not there as if it never got created in first place....

 

Hmm, I think I would have to delve deep into the UDF or hopefully the author can shed some light on the subject (last active in july though :( )


Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
Share on other sites

Hi,

Thanks for the code ... Tried it in Win PE 7 with all the services running like VSS and such ... when i called the _SR_Enable("C:\") function it returned 0 ...

i also been trying to get it to enable in powershell and it fails there too saying it not system drive (but it is for sure) ...

I can get recenv.exe to do a computer restore point so i figured WMI would do it or PS ...

Any ideas on why it failing ?

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0