Community | RoboIntern
Schedule windows system restore - Printable Version

+- Community | RoboIntern (https://robointern.tech/community)
+-- Forum: RoboIntern Forum (https://robointern.tech/community/forumdisplay.php?fid=1)
+--- Forum: How To / Q&A (https://robointern.tech/community/forumdisplay.php?fid=2)
+--- Thread: Schedule windows system restore (/showthread.php?tid=38)



Schedule windows system restore - jimcuk - 09-01-2019

Hi
as the title says , I would be interested to know if this could be done, as I am having problems with windows task scheduler.
I have only just downloaded the program and I must say you have the GUI looking great.


RE: Schedule windows system restore - RoboIntern - 09-21-2019

Hi jimcuk!

Apologies for the late reply, I just needed some time to look into this.

You can automate system restores with a small trick, which involves creating a VBScript. These are the steps:
1. Create a new text file and then paste the code below into it
2. Rename the file to extension to .vbs (instead of .txt)
3. Set up a task in RoboIntern with action "Run a VB script" (it's at the very end of the list)

And that should be it. It will take the latest created restore point. You can disable the prompt by putting a ' in the vbs file in front of the If MsgBox(.. and End If lines.
Also make sure to update RoboIntern to the latest version (1.022).

Let me know if it worked!

Code for text file:
If Not WScript.Arguments.Named.Exists("elevate") Then
  CreateObject("Shell.Application").ShellExecute WScript.FullName _
    , """" & WScript.ScriptFullName & """ /elevate", "", "runas", 1
WScript.Quit
End If

Dim RP
Set RPSet = GetObject("winmgmts:root/default").InstancesOf("SystemRestore")

i=1

For Each RP in RPSet
If i = RPSet.Count Then

If MsgBox("*** Last restore point found: ***" & Chr(10) & Chr(10) & "RP ID: " & RP.SequenceNumber & Chr(10) & "Name: " & RP.Description & Chr(10) & "Type:  " & RP.RestorePointType & Chr(10) & "Time:  " & RP.CreationTime & Chr(10) & Chr(10) & "Restore?", vbYesNo, "Yes No Example") = vbYes Then
Set obj = GetObject("winmgmts:{impersonationLevel=impersonate}!root/default:SystemRestore")
if obj.Restore(RP.SequenceNumber) <> 0 Then
wscript.Echo "Restore failed"
End If

Set OpSysSet = GetObject("winmgmts:{(Shutdown)}//./root/cimv2").ExecQuery("select * from Win32_OperatingSystem where Primary=true")
for each OpSys in OpSysSet
OpSys.Reboot()
next
End If
End If

i = i + 1
Next