FredAI

System restore UDF

11 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

#10 ·  Posted

Please change:
_WMIDateStringToDate
to
__SR_WMIDateStringToDate

to be coherent with other function names and because this is internal function.

btw.
I modified it a little (to be more HumanReadabled) :
 

Func __SR_WMIDateStringToDate($dtmDate)
    Return _
            (StringMid($dtmDate, 5, 2) & "/" & _
            StringMid($dtmDate, 7, 2) & "/" & _
            StringLeft($dtmDate, 4)  & " " & _
            StringMid($dtmDate, 9, 2) & ":" & _
            StringMid($dtmDate, 11, 2) & ":" & _
            StringMid($dtmDate, 13, 2))
EndFunc   ;==>__SR_WMIDateStringToDate

 


Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * 

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2017-06-04

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

I just modified your UDF, a little ;)

No breaking Changes (I hope).

SystemRestore.au3

 

Edited by mLipok
1 person likes this

Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * 

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2017-06-04

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