radix Posted May 1, 2012 Share Posted May 1, 2012 (edited) Is possible to disable the system restore on all drives in Windows 7 using vb scripting ?The only solution I have right now is a reg file obtained by using RegShot, but I guess it's not work on other computers:Windows Registry Editor Version 5.00[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SPP\Clients]"{09F7EDC5-294E-4180-AF6A-FB0E6A0E9513}"=-"{3E7F07C9-6BC3-11DC-A033-0019B92BB8B1}"=-[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SystemRestore]"RPSessionInterval"=dword:00000000 Edited May 1, 2012 by radix Link to comment Share on other sites More sharing options...
Yzöwl Posted May 1, 2012 Share Posted May 1, 2012 The following is what I used to use on XP systems.strComputer = "."Set objWMISvc = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\default")Set objItem = objWMISvc.Get("SystemRestore")errResults = objItem.Disable("")Disabling the service essentially prevents the System Restore on all drives.Changing the last word to Enable would obviusly reverse the action.Here's one which will cover both scenarios'Enable or Disable System RestorestrComputer = InputBox("Enter the COMPUTER NAME or the IP ADDRESS of the " _ & "system on which you would like to Enable or Disable System Restore. " _ & vbCRLF & "(use localhost for current system)", "Remotely Enable or " _ & "Disable System Restore","localhost")If strComputer = "" Then WScript.QuitEnd If strChoice = Inputbox ("System Restore:" & vbCrLf & vbCrLf & "1: Enable" _ & vbCrLf & "2: Disable" & vbCrLf & vbCrLf & vbCrLf & "Please enter 1 or 2 " _ & "(leave blank to quit):", "Enter 1 to Enable or 2 to Disable","")If strChoice = "" Then WScript.QuitEnd If If strChoice = 1 Then Set objWMISvc = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\default") Set objItem = objWMISvc.Get("SystemRestore") errResults = objItem.Enable("") Mybox = MsgBox("System Restore is now enabled on " & strComputer & "" _ & vbCRLF ,vbOkOnly,"System Restore Enabled")End IfIf strChoice = 2 Then Set objWMISvc = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\default") Set objItem = objWMISvc.Get("SystemRestore") errResults = objItem.Disable("") Mybox = MsgBox("System Restore is now disabled on " & strComputer & "" _ & vbCRLF ,vbOkOnly,"System Restore Disabled")End If Link to comment Share on other sites More sharing options...
radix Posted May 1, 2012 Author Share Posted May 1, 2012 Thanks, but not working. It seems the only way to turn off the system restore in Windows 7 is by using registry tweaks. Link to comment Share on other sites More sharing options...
Yzöwl Posted May 1, 2012 Share Posted May 1, 2012 Did you run it elevated? Link to comment Share on other sites More sharing options...
radix Posted May 1, 2012 Author Share Posted May 1, 2012 Did you run it elevated?Yes. Link to comment Share on other sites More sharing options...
CoffeeFiend Posted May 2, 2012 Share Posted May 2, 2012 There's a good reason why it doesn't work anymore: the system restore service doesn't exist on Win7 (setting a non-existent service to disabled accomplishes nothing). There's no straight replacement for it so you can't just disable a service anymore.The easiest thing to do now is to use the Disable-ComputerRestore in PowerShell e.g.Disable-ComputerRestore "C:\", "D:\"But you can still do it in VBScript using the relevant WMI classes if that's what you prefer, or even using WMI in PowerShell:([wmiclass]"\\.\root\default:systemrestore").Disable("C:\") Link to comment Share on other sites More sharing options...
Yzöwl Posted May 2, 2012 Share Posted May 2, 2012 I believe that with the Disable method of the WMI SystemRestore class an empty string, (""), can be used as a parameter if you wish to disable System Restore for all drives.Alternatively, try this. Link to comment Share on other sites More sharing options...
CoffeeFiend Posted May 2, 2012 Share Posted May 2, 2012 with the Disable method of the WMI SystemRestore class an empty string, (""), can be used as a parameter if you wish to disable System Restore for all drivesAccording to the documentation it should work (just like it would also work for my WMI example above):ParametersDrive [in]The drive to be disabled. The drive string should be of the form "C:\". If this parameter is the system drive or an empty string (""), no drives are monitored.Not that I tested any of it (I'm too lazy to enable it on multiple drives just to test disabling it) Link to comment Share on other sites More sharing options...
radix Posted May 2, 2012 Author Share Posted May 2, 2012 OK, thanks ! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now