yet another blog about computer, technology, programming, and internet

Tuesday, June 27, 2006

Creating a Restore Point Using Windows Management Instrumentation (WMI) and C#.NET

Tuesday, June 27, 2006 Posted by Ismail Habib , , 51 comments
I have tried to find a way to create a restore point in Windows, but no matter how hard I tried, I just can't find the one using C#, one of my favourite language. Sigh, I have to make one on my own :P Windows has something called WMI (Windows Management Instrumentation). It contains a huge classes and objects that allow programmers to do a lot of things, creating a restore point is just one of them.
Here is the source code to create a restore point in Windows:

ManagementScope oScope = new ManagementScope("\\\\localhost\\root\\default");
ManagementPath oPath = new ManagementPath("SystemRestore");
ObjectGetOptions oGetOp = new ObjectGetOptions();
ManagementClass oProcess = new ManagementClass(oScope,oPath,oGetOp);

ManagementBaseObject oInParams = oProcess.GetMethodParameters("CreateRestorePoint");
oInParams["Description"] = "My Restore Point";
oInParams["RestorePointType"] = 0;
oInParams["EventType"] = 100;

ManagementBaseObject oOutParams = oProcess.InvokeMethod("CreateRestorePoint", oInParams, null);

Hope this will be useful. Don't forget to add System.Management as a reference!


  1. Tester12:17 AM

    I get an error on Vista using above code.

    Unhandled Exception: System.Runtime.InteropServices.COMException (0x800423F4)
    at System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(Int32 errorCode
    , IntPtr errorInfo)
    at System.Management.ManagementObject.InvokeMethod(String methodName, Managem
    entBaseObject inParameters, InvokeMethodOptions options)

  2. Thanks for the comment. Unfortunately, this code is written for Windows XP and I am not sure if it's going to work in another version of Windows.

  3. Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging. If anyone wants to become a .Net developer learn from Dot Net Training in Chennai. or learn thru ASP.NET Essential Training Online . Nowadays Dot Net has tons of job opportunities on various vertical industry.
    or Javascript Training in Chennai. Nowadays JavaScript has tons of job opportunities on various vertical industry.

  4. Beberapa tips cara menggugurkan kandungan dengan asam jawa untuk anda dengan menggunakan obat penggugur kandungan cytotec , terbukti dengan cepat untuk cara mencegah kehamilan . Maka dari itu pilihlah obat aborsi sangat ampuh . Jika anda telah haid obat telat datang bulan juga manjur , kami jual obat aborsi ini secara online cara menggugurkan hamil

  5. Thanks Admin for sharing such a useful post, I hope it’s useful to many individuals for developing their skill to get good career.
    Selenium training in Chennai

    Selenium training in Bangalore

  6. After reading this web site I am very satisfied simply because this site is providing comprehensive knowledge for you to audience.
    Thank you to the perform as well as discuss anything incredibly important in my opinion. We loose time waiting for your next article writing in addition to I beg one to get back to pay a visit to our website in

    Selenium training in bangalore
    Selenium training in Chennai
    Selenium training in Bangalore
    Selenium training in Pune
    Selenium Online training

  7. thanks for your information really good and very nice web design company in velachery