Conduct a System Restore

Performs a system restore on a computer using system restore point No. 20. To perform a system restore using a different system restore point, simply change the value of the const

 
 
 
 
 
(0)
Add to favorites
8/10/2009
E-mail Twitter del.icio.us Digg Facebook
Sign in to ask a question


  • auto restore Win7 to previous restore point
    5 Posts | Last post August 09, 2011
    • Hello, I tried using this VB script in Win7's Group policy console for a standard user so that when they log off it runs this & supposedly restores to restore point 17. Unfortunately when I log off as that local standard user it tries to run the script & gives me this error:
      
      C:\Windows\System32\GroupPolicyUsers\S-1-5-21-295869779-165616507-326401329-1001\User\Script\LogOff\SystemRestoreEDR.vbs
      Line: 8
      Char: 1
      Error: Access Denied
      Code: 80041003
      Source: SWbemObjectEx
      
      Is there something that needs to be changed for it to work in Windows 7? I am running Win 7 Pro x86.
      
      Thank you!
      
      Craig
    • I executed the VBScript "Conduct a System Restore" on two different OS (XP and Vista) and nothing happened.
      I'm not surprised, it seems that the scripting guys do not know what they are talking about.
      For the umpteenth time...
      
      Angel
    • The two parts that jumped out at me were:
      
      ... for a standard user...
      and
      ... Line: 8 Char: 1 Error: Access Denied ...
      
      I wasn't aware standard users were allowed to run a System Restore. Try elevating the script with RunAs or similar.
    • The following code would be a better way to execute a Restore Point with related SequenceNumber.
      By the way, for those who don't know it yet, 
      copy the code and paste it in Notepad, save (Save as) with the extension .vbs
      
      _____________________________________
      
      
      Set cP = CreateObject("Scripting.FileSystemObject") 
      Set rP = cP.CreateTextFile("SequenceNR.txt", True)
      Set CDatum = CreateObject("WbemScripting.SWbemDateTime")
      strComputer = "."
      Set oWm = GetObject("winmgmts:\\" & strComputer & "\root\default")
      Set cli = oWm.ExecQuery("Select * from SystemRestore")
      For Each objItem in cli
      CDatum.Value = objItem.CreationTime
      dtmCreationTime = CDatum.GetVarDate
      rP.WriteLine + objItem.Description & "   -   " & dtmCreationTime & "   /   SequenceNumber is :  " & objItem.SequenceNumber
      Next
      Function bp
      Set objNetwork = CreateObject("WScript.Network")
      bp = objNetwork.UserName
      End Function
      a = InputBox(vbCr & "Hi " & bp  & vbCrLf & vbCrLf &_
      "A file named " & chr(34) & "SequenceNR.txt" & chr(34) & vbCrLf &_
      "with information on the Restore Points" & vbCrLf &_
      "and related SequenceNumber," & vbCrLf &_
      "is created in this folder." & vbCrLf & vbCrLf &_
      "Enter the SequenceNumber of the Restore Point." , "Run Restore Point")
      If a = "" Then
      Set a = Nothing
      WScript.Quit
      End If
      strComputer = "."
      Set objWMIService = GetObject("winmgmts:" _
      & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\default")
      Set objItem = objWMIService.Get("SystemRestore")
      errResults = objItem.Restore(a)
      Set OpSysSet = GetObject("winmgmts:{(Shutdown)}//./root/cimv2").ExecQuery("select * from Win32_OperatingSystem where Primary=true")
      for each OpSys in OpSysSet
      OpSys.Reboot()
      next
      
      _____________________________________
      
    • Apparently, this text-editor seems to write everything on the same line.
      This way de above code won't work. 
      I've put a colon between every new line, that way the code should work even if it's all on the same line.
      Hopefully this editor doesn't screw things up again. Code start ---> Set cP = CreateObject("Scripting.FileSystemObject") : Set rP = cP.CreateTextFile("SequenceNR.txt", True) : Set CDatum = CreateObject("WbemScripting.SWbemDateTime") : strComputer = "." : Set oWm = GetObject("winmgmts:\\" & strComputer & "\root\default") : Set cli = oWm.ExecQuery("Select * from SystemRestore") : For Each objItem in cli : CDatum.Value = objItem.CreationTime : dtmCreationTime = CDatum.GetVarDate : rP.WriteLine + objItem.Description & "   -   " & dtmCreationTime & "   /   SequenceNumber is :  " & objItem.SequenceNumber : Next : Function bp : Set objNetwork = CreateObject("WScript.Network") : bp = objNetwork.UserName : End Function : a = InputBox(vbCr & "Hi " & bp  & vbCrLf & vbCrLf & "A file named " & chr(34) & "SequenceNR.txt" & chr(34) & vbCrLf & "with information on the Restore Points" & vbCrLf & "and related SequenceNumber," & vbCrLf & "is created in this folder." & vbCrLf & vbCrLf & "Enter the SequenceNumber of the Restore Point." , "Run Restore Point") : If a = "" Then : Set a = Nothing : WScript.Quit : End If : strComputer = "." : Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\default") : Set objItem = objWMIService.Get("SystemRestore") : errResults = objItem.Restore(a) : Set OpSysSet = GetObject("winmgmts:{(Shutdown)}//./root/cimv2").ExecQuery("select * from Win32_OperatingSystem where Primary=true") : For Each OpSys In OpSysSet : OpSys.Reboot() : Next