Listing 1: DisableSystemRestore.vbs Option Explicit Dim strComputerName, blnEnabled, objRP, lngRC ' BEGIN COMMENT ' If there are no command-line parameters, assume the local computer. ' END COMMENT If WScript.Arguments.Count = 0 Then strComputerName = CreateObject("WScript.Network").ComputerName Else strComputerName = WScript.Arguments(0) End If ' BEGIN CALLOUT A ' BEGIN COMMENT ' Check to see whether the computer has any restore points. ' END COMMENT blnEnabled = False For Each objRP In GetObject("WinMgmts:" _ & "{impersonationlevel=impersonate}!//" & strComputerName _ & "/root/default").InstancesOf("SystemRestore") blnEnabled = True Exit For Next ' END CALLOUT A lngRC = 0 ' BEGIN CALLOUT B If blnEnabled Then ' BEGIN COMMENT ' Disable System Restore for all drives on the computer. ' END COMMENT lngRC = GetObject("WinMgmts:" _ & "{impersonationlevel=impersonate}!//" & strComputerName _ & "/root/default:SystemRestore").Disable("") If lngRC = 0 Then WScript.Echo "Disabled System Restore on " _ & strComputerName & "." Else WScript.Echo "Error &H" & Hex(lngRC) & " disabling System Restore" _ & " on " & strComputerName & "." End If Else WScript.Echo "System Restore is already disabled on " _ & strComputerName & "." End If ' END CALLOUT B WScript.Quit lngRC