Archive: Create a Windows System Restore Point


Create a Windows System Restore Point
Does anyone know how to make the installer create a system restore point with a description?

{EDIT}

Also, does anyone know how to have the installer empty the trash can?

{/EDIT}


1. That would be cool! I don't know that API.
2. This code can give you some start points...


I currently use a VBS file the installer extracts to create a system restore point, however you can't use "ExecWait" on vbs files, so I use sleep but since computer speeds and restore space allotments vary on every system, the wait time isn't always right.

Here's the VB Script code:

'Unattended System Restore Point
'sysrestorepoint.vbs
'© Doug Knox - rev 02/11/2002
'Downloaded from www.dougknox.com
'Extracted from original code by Bill James - www.billsway.com

Set sr = getobject("winmgmts:\\.\root\default:Systemrestore")

msg = "New Restore Point successfully created." & vbCR
msg = msg & "It is listed as: " & vbCR
msg = msg & "Automatic Restore Point " & Date & " " & Time

'Put a ' in front of the next five lines to disable the Success Failed Prompt.
If (sr.createrestorepoint("Automatic Restore Point", 0, 100)) = 0 Then
MsgBox msg
Else
MsgBox "Restore Point creation Failed!"
End If

'Remove the ' from the next 3 lines to only alert you if the process failed
'If (sr.createrestorepoint("Automatic Restore Point", 0, 100)) <> 0 Then
' MsgBox "Restore Point creation Failed!"
'End If


If someone can convert that into installer API calls or something then we wouldn't need an external .vbs file.

Something in MSDN