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
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
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)
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