Jump to content

System restore through a batch file


Recommended Posts

Hi everybody!

Help me please! I need to create a system restore point by a batch file or by a vbs-script (I mean without System Restore's GUI). So, I have a VBS-script which does not work:

Set IRP = getobject("winmgmts:\.\root\default:Systemrestore")
MYRP = IRP.createrestorepoint ("Restore", 0, 100)

There is an error:

Script: I:\restore.vbs
Line: 1
Symbol: 1
Error: 0x80041021
Code: 80041021
Source: (null)

So, who can help me?

PS I'm so sorry for my English - Russian is my native language... :D:rolleyes:

Link to comment
Share on other sites


Here is a Vbs script that will set a restore point

Save As CreateSRPoint.vbs

Option Explicit
'-> Varibles
Dim Chk1, Chk2, Chk3, CSRP, RP, SRName, SRP
'-> Get User Input
SRName = InputBox("Type in the name for the SystemRestore.")
'-> Checks Input Then Starts The Restore Process
If SRName = "" Then 'Cancel Reply
Chk1 = True
ElseIf Len(SRName) = 0 Then 'Ok Was Pushed But Nothing In The Inputbox
Chk1 = True
ElseIf Len(SRName) > 3 Then 'Make Sure There At Least 3 Characters
'-> Make The Restore Point
Set SRP = GetObject("winmgmts:\\.\root\default:Systemrestore")
CSRP = SRP.createrestorepoint(SRName, 0, 100)
'-> Check To See If It Was Created
Set SRP = GetObject("winmgmts:root/default").InstancesOf ("SystemRestore")
For Each RP In SRP
If InStr(RP.Description,SRName) Then
Chk1 = False
Chk2 = False
Chk3 = True
End If
Next
Else 'Less The 3 Characters
Chk2 = True
End If
'-> Report Back
If Chk1 = True Then
Msgbox "There Was No User Input Cannot Create Restore Point", 4128, "Error No Input"
WScript.Quit(0)
End If
If Chk2 = True Then
Msgbox "There Needs To Be 3 Charters For It To Be Valid", 4128, "Not Valid"
WScript.Quit(0)
End If
If Chk3 = True Then
Msgbox "The New System Restore Point Has Been Created", 4128, "Confirm Restore Point"
Else
Msgbox vbtab & "Error Unknown" & vbCrLf & "System Restore Point Not Created", 4128, "Error Unknown"
End If

Link to comment
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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...