|
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\GroupPolic yUsers\S-1-5-21 -295869779-1656 16507-326401329 -1001\User\Scri pt\LogOff\Syste mRestoreEDR.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("S cripting.FileSy stemObject") Set rP = cP.CreateTextFi le("SequenceNR. txt", True) Set CDatum = CreateObject("W bemScripting.SW bemDateTime") strComputer = "." Set oWm = GetObject("winm gmts:\\" & strComputer & "\root\default" ) Set cli = oWm.ExecQuery(" Select * from SystemRestore") For Each objItem in cli CDatum.Value = objItem.Creatio nTime dtmCreationTime = CDatum.GetVarDa te rP.WriteLine + objItem.Descrip tion & " - " & dtmCreationTime & " / SequenceNumber is : " & objItem.Sequenc eNumber Next Function bp Set objNetwork = CreateObject("W Script.Network" ) bp = objNetwork.User Name 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("winm gmts:" _ & "{impersonation Level=impersona te}!\\" & strComputer & "\root\default" ) Set objItem = objWMIService.G et("SystemResto re") errResults = objItem.Restore (a) Set OpSysSet = GetObject("winm gmts:{(Shutdown )}//./root/cimv 2").ExecQuery(" select * from Win32_Operating System 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.FileSy stemObject") : Set rP = cP.CreateTextFi le("SequenceNR. txt", True) : Set CDatum = CreateObject("W bemScripting.SW bemDateTime") : strComputer = "." : Set oWm = GetObject("winm gmts:\\" & strComputer & "\root\default" ) : Set cli = oWm.ExecQuery(" Select * from SystemRestore") : For Each objItem in cli : CDatum.Value = objItem.Creatio nTime : dtmCreationTime = CDatum.GetVarDa te : rP.WriteLine + objItem.Descrip tion & " - " & dtmCreationTime & " / SequenceNumber is : " & objItem.Sequenc eNumber : Next : Function bp : Set objNetwork = CreateObject("W Script.Network" ) : bp = objNetwork.User Name : 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("winm gmts:" & "{impersonation Level=impersona te}!\\" & strComputer & "\root\default" ) : Set objItem = objWMIService.G et("SystemResto re") : errResults = objItem.Restore (a) : Set OpSysSet = GetObject("winm gmts:{(Shutdown )}//./root/cimv 2").ExecQuery(" select * from Win32_Operating System where Primary=true") : For Each OpSys In OpSysSet : OpSys.Reboot() : Next