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.
Page 1 of 1
wmic to disable system restore
#2
Posted 01 August 2010 - 04:47 PM
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?
Why not use HKLM\SOFTWARE\Policies\Microsoft\Windows NT\SystemRestore\DisableConfig to disable it completely?
#3
Posted 01 August 2010 - 10:08 PM
Disabling systeme restore with gpo via registry is there: HKLM\SOFTWARE\Policies\Microsoft\Windows NT\SystemRestore\DisableSR
#4
Posted 01 August 2010 - 10:40 PM
if I use wmic then the restore points will be deleted.
#5
Posted 01 August 2010 - 11:10 PM
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:
Very 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.
Option Explicit
Dim oWMI, oSR, colItem, objItem
Set 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 & "\")
Next
Very 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.
- ← Retrieving the COM class factory for component with CLSID failed due t
- Programming (C++, Delphi, VB/VBS, CMD/batch, etc.)
- Gui for command line help! →
Share this topic:
Page 1 of 1



Help
Back to top









