MSFN Forum: wmic to disable system restore - MSFN Forum

Jump to content


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

wmic to disable system restore Rate Topic: -----

#1 User is offline   patronu 

  • Junior
  • Pip
  • Group: Members
  • Posts: 85
  • Joined: 19-June 05

Posted 01 August 2010 - 03:47 PM

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.


#2 User is offline   CoffeeFiend 

  • Coffee Aficionado
  • Group: Super Moderator
  • Posts: 5,399
  • Joined: 14-July 04
  • OS:Windows 7 x64
  • Country: Country Flag

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?

#3 User is offline   allen2 

  • Not really Newbie
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 1,736
  • Joined: 13-January 06

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 User is offline   patronu 

  • Junior
  • Pip
  • Group: Members
  • Posts: 85
  • Joined: 19-June 05

Posted 01 August 2010 - 10:40 PM

if I use wmic then the restore points will be deleted.

#5 User is offline   CoffeeFiend 

  • Coffee Aficionado
  • Group: Super Moderator
  • Posts: 5,399
  • Joined: 14-July 04
  • OS:Windows 7 x64
  • Country: Country Flag

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:

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.

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users



All trademarks mentioned on this page are the property of their respective owners
Copyright © 2001 - 2013 msfn.org
Privacy Policy