Created
July 1, 2017 11:00
-
-
Save kek-Sec/23604e7b3af41592a934dc41f836c17a to your computer and use it in GitHub Desktop.
C# Find and Delete system restore points
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Management; | |
using System.Runtime.InteropServices; | |
[DllImport("Srclient.dll")] | |
public static extern int DeleteRestorePoint(int index); | |
private void SearchAndDestroySystemRestore() | |
{ | |
//Find sequence numbers of system restore points | |
System.Management.ManagementClass objClass = new System.Management.ManagementClass("\\\\.\\root\\default", "systemrestore", new System.Management.ObjectGetOptions()); | |
System.Management.ManagementObjectCollection objCol = objClass.GetInstances(); | |
String[] sequencenums = new String[100]; | |
int c = 0; | |
foreach (System.Management.ManagementObject objItem in objCol) | |
{ | |
sequencenums[c] = (((uint)objItem["sequencenumber"]).ToString()); | |
c++; | |
} | |
//Delete them | |
while (c >= 0) | |
{ | |
DeleteRestorePoint(Convert.ToInt32(sequencenums[c])); | |
c--; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment