patronu Posted August 1, 2010 Posted August 1, 2010 How to disable system restore on all drives using wmic?This command works for the specified drive. wmic /namespace:\\root\default path SystemRestore call Disable %SystemDrive%\ Also I can use wmic to list drive letter usig wmic logicaldisk get caption. But I don't know how to combine these two commands. Anyone can help?thank you.
CoffeeFiend Posted August 1, 2010 Posted August 1, 2010 Why even do it this way if you want to disable it for the entire machine?Why not use HKLM\SOFTWARE\Policies\Microsoft\Windows NT\SystemRestore\DisableConfig to disable it completely?
allen2 Posted August 2, 2010 Posted August 2, 2010 Disabling systeme restore with gpo via registry is there: HKLM\SOFTWARE\Policies\Microsoft\Windows NT\SystemRestore\DisableSR
patronu Posted August 2, 2010 Author Posted August 2, 2010 if I use wmic then the restore points will be deleted.
CoffeeFiend Posted August 2, 2010 Posted August 2, 2010 Ok then. WMIC merely makes calls to WMI methods, so here's a quick and dirty vbscript that makes the same query and calls the exact same method:Option ExplicitDim oWMI, oSR, colItem, objItemSet oWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")Set oSR = GetObject("winmgmts:{impersonationLevel=impersonate}!root/default:SystemRestore")Set colItem = oWMI.ExecQuery("SELECT * FROM Win32_LogicalDisk WHERE DriveType=3")For Each objItem in colItem oSR.Disable(objItem.DeviceID & "\")NextVery little testing of any kind has been done (only 1 VM, with 1 drive, once) but it seems to work fine (even the restore points got deleted)Edit: the board seems to screw up the code formatting, especially with code tags (still messed up with quote tags or none at all). Watch for the parenthesis after cimv2... It should be on the same line, and if you see a space there, then it's the board that insists on adding it for no good reason. If you hit the "reply" button, you'll seemingly be able to copy/paste the code in its un-crippled format from there. Sorry about that, there's nothing I can do to make IPB work as you'd expect it to.
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now