[SOLVED]Silent restore point

Discussion in 'Mixed Languages' started by Muerto, Aug 7, 2012.

  1. Muerto

    Muerto MDL Debugger

    Mar 7, 2012
    1,855
    2,102
    60
    #1 Muerto, Aug 7, 2012
    Last edited: Jan 12, 2021
    ...
     
  2. stevemk14ebr

    stevemk14ebr MDL Senior Member

    Jun 23, 2010
    267
    48
    10
    #2 stevemk14ebr, Aug 7, 2012
    Last edited by a moderator: Apr 20, 2017
    adapted from http://www.freevbcode.com/ShowCode.asp?ID=6911

    Code:
     Public Class Form1
    
        Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
            Call ListPoints()
            Dim obj As Object
            obj = GetObject("winmgmts:{impersonationLevel=impersonate}!root/default:SystemRestore")
    
            'The date and ID are auto added
            Call obj.CreateRestorePoint("Give it a name", 12, 100)
    
        End Sub
       
    
     Public Sub ListPoints() 'Adds all Restore Points to a ListView
    
            Dim o As Object
            Dim sr As Object
            Dim num As Byte
    
            'Get all points and add them to "o"
            o = GetObject("winmgmts:root/default").InstancesOf("SystemRestore")
    
            'Scroll through "o"
            For Each sr In o
                num += 1
                'Adds a point to a ListView then shows num of restore not that after 
                'creating the restore it will not show a nother restore until restarting app
                ListView2.Items.Add(sr)
                MessageBox.Show(num)
    
    
    
            Next sr
    
        End Sub
    End Class
    P.S is it time for me to join you in coding or are u finalizing stuff before u send it, or am i no longer working on it
     
  3. Muerto

    Muerto MDL Debugger

    Mar 7, 2012
    1,855
    2,102
    60
    #3 Muerto, Aug 7, 2012
    Last edited: Jan 12, 2021
    (OP)
    ...
     
  4. stevemk14ebr

    stevemk14ebr MDL Senior Member

    Jun 23, 2010
    267
    48
    10
    #4 stevemk14ebr, Aug 7, 2012
    Last edited by a moderator: Apr 20, 2017
    ok good to hear and btw u only need this sub to make the restore
    Code:
     Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
            Call ListPoints()
            Dim obj As Object
            obj = GetObject("winmgmts:{impersonationLevel=impersonate}!root/default:SystemRestore")
    
            'The date and ID are auto added
            Call obj.CreateRestorePoint("Give it a name", 12, 100)
    
        End Sub
    the other sub is just to keep tabs how many restore points u hav, didn't know if u caught that
     
  5. Muerto

    Muerto MDL Debugger

    Mar 7, 2012
    1,855
    2,102
    60
    #5 Muerto, Aug 7, 2012
    Last edited: Jan 12, 2021
    (OP)
    ...
     
  6. Alphawaves

    Alphawaves Super Moderator/Developer
    Staff Member

    Aug 11, 2008
    6,222
    22,280
    210
    #6 Alphawaves, Aug 7, 2012
    Last edited by a moderator: Apr 20, 2017
    I think if its just for a tweaks option then something simple..

    Code:
    Dim ogo As New ObjectGetOptions()
    Dim mclass As New ManagementClass("\\localhost\root\default", "SystemRestore", ogo)
    Dim obj As ManagementBaseObject = mclass.GetMethodParameters("CreateRestorePoint")
    obj("Description") = "My restore name"
    obj("RestorePointType") = 0
    obj("EventType") = 100
    Dim OutParams As ManagementBaseObject = mclass.InvokeMethod("CreateRestorePoint", obj, Nothing)
     
  7. Muerto

    Muerto MDL Debugger

    Mar 7, 2012
    1,855
    2,102
    60
    #7 Muerto, Aug 7, 2012
    Last edited: Jan 12, 2021
    (OP)
    ...
     
  8. stevemk14ebr

    stevemk14ebr MDL Senior Member

    Jun 23, 2010
    267
    48
    10
    #8 stevemk14ebr, Aug 8, 2012
    Last edited: Aug 8, 2012
    there is one advantage to my original code- you don't need to referance any dll's :/

    EDIT-alpha i was fooling around with the same exact code as that (before i posted the one above) but i couldn't declare any of the managment stuff, turns out i forgot to referance the dll lol
     
  9. Muerto

    Muerto MDL Debugger

    Mar 7, 2012
    1,855
    2,102
    60
    #9 Muerto, Aug 8, 2012
    Last edited: Jan 12, 2021
    (OP)
    ...
     
  10. Muerto

    Muerto MDL Debugger

    Mar 7, 2012
    1,855
    2,102
    60
    #10 Muerto, Aug 8, 2012
    Last edited: Jan 12, 2021
    (OP)
    ...