Option Explicit
' Wdp_control.currentstatusConst wdp_active = 0 Const wdp_passive = 1 ' Wdp_control.currentmodeConst wdp_mode_discard = 0 ' Remove all changes on restartConst wdp_mode_persist = 1 Const wdp_mode_commit = 2 ' Keep all changes permanentlyDim objswbemlocator Set objswbemlocator=createobject("WbemScripting.SWbemLocator") Dim objswbemservices Set objswbemservices=objswbemlocator. ConnectServer (".","Root\wmi")Dim objswbemobjectset Set objswbemobjectset=objswbemservices. InstancesOf ("Wdp_control")'ReadCurrentstatusPropertiesDim currentstatus Dim OBJSWBEMOBJECTWDP forEach objswbemobjectwdp in objswbemobjectset currentstatus=objswbemobjectwdp. currentstatus Next'onlyCurrentstatusproperty iswdp_active, you can applyCurrentModeproperty. If wdp_active=currentstatus ThenFor each objswbemobjectwdp in objswbemobjectset OBJSWBEMOBJECTWDP. CurrentMode = Wdp_mode_commit ' SWbemObject of thePut_method to update the property to theWMIin to OBJSWBEMOBJECTWDP. Put_ Next MsgBox " successfully set to"Keep all changes permanently"state. ",and," Tips"Else MsgBox " The disk protection feature is not turned on! "End If 'Note: Each class in Scripting API objects contains an abbreviated WBEM,Wbemis an industry initiative that regulates the description and use of managed resources in enterprise networks, and isweb-based Enterprise Managementthe shorthand, in factWBEMis a kind of management standard for computer equipment,WMIIt 's Microsoft's.Windowsin theWbema concrete implementation of the aspect.
Using WMI scripts to manipulate SteadyState, set the disk protection feature to "keep all changes permanently"