Gobillot
Messages postés3140Date d'inscriptionvendredi 14 mai 2004StatutMembreDernière intervention11 mars 201934 3 juil. 2006 à 12:44
ben je sais pas trop
comme c'est en Net faut surement adapter à cause des différences de types
et comme ça à l'air délicat parce que le Set peut aussi bien créer que utiliser, donc imposer un point de Restauration
à un utilisateur (même à soi même) c'est pas le top
faut mieux maitriser avant de se lancer
j'ai encore jamais utilisé le Set, mais j'ai déjà utilisé le Remove,
qui est tout simple à utiliser, il suffit de mettre le numéro
correspondant, ensuite on supprime les fichiers du répertoire et ça
fait gagner de la place.
SRSetRestorePointA
SRRemoveRestorePoint
Daniel
Vous n’avez pas trouvé la réponse que vous recherchez ?
Public Class CallWMIMethod
Inherits System.Windows.Forms.Form
Friend WithEvents userNameLabel As System.Windows.Forms.Label
Friend WithEvents userNameBox As System.Windows.Forms.TextBox
Friend WithEvents passwordBox As System.Windows.Forms.TextBox
Friend WithEvents passwordLabel As System.Windows.Forms.Label
Friend WithEvents OKButton As System.Windows.Forms.Button
Friend WithEvents closeButton As System.Windows.Forms.Button
Private components As System.ComponentModel.IContainer
Public Sub New()
MyBase.New()
InitializeComponent()
End Sub
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.userNameLabel = new System.Windows.Forms.Label
Me.userNameBox = new System.Windows.Forms.TextBox
Me.passwordBox = new System.Windows.Forms.TextBox
Me.passwordLabel = new System.Windows.Forms.Label
Me.OKButton = new System.Windows.Forms.Button
Me.closeButton = new System.Windows.Forms.Button
Me.SuspendLayout()
'
' userNameLabel
'
Me.userNameLabel.Location = New System.Drawing.Point(16, 8)
Me.userNameLabel.Name = "userNameLabel"
Me.userNameLabel.Size = New System.Drawing.Size(160, 32)
Me.userNameLabel.TabIndex = 0
Me.userNameLabel.Text = "Enter the user name for the remote computer:"
'
' userNameBox
'
Me.userNameBox.Location = New System.Drawing.Point(160, 16)
Me.userNameBox.Name = "userNameBox"
Me.userNameBox.Size = New System.Drawing.Size(192, 20)
Me.userNameBox.TabIndex = 1
Me.userNameBox.Text = ""
'
' passwordBox
'
Me.passwordBox.Location = New System.Drawing.Point(160, 48)
Me.passwordBox.Name = "passwordBox"
Me.passwordBox.PasswordChar = "*"
Me.passwordBox.Size = new System.Drawing.Size(192, 20)
Me.passwordBox.TabIndex = 3
Me.passwordBox.Text = ""
'
' passwordLabel
'
Me.passwordLabel.Location = new System.Drawing.Point(16, 48)
Me.passwordLabel.Name = "passwordLabel"
Me.passwordLabel.Size = new System.Drawing.Size(160, 32)
Me.passwordLabel.TabIndex = 2
Me.passwordLabel.Text = "Enter the password for the remote computer:"
'
' OKButton
'
Me.OKButton.Location = New System.Drawing.Point(40, 88)
Me.OKButton.Name = "OKButton"
Me.OKButton.Size = new System.Drawing.Size(128, 23)
Me.OKButton.TabIndex = 4
Me.OKButton.Text = "OK"
'
' closeButton
'
Me.closeButton.DialogResult = System.Windows.Forms.DialogResult.Cancel
Me.closeButton.Location = New System.Drawing.Point(200, 88)
Me.closeButton.Name = "closeButton"
Me.closeButton.Size = New System.Drawing.Size(128, 23)
Me.closeButton.TabIndex = 5
Me.closeButton.Text = "Cancel"
'
' MyQuerySample
'
Me.AcceptButton = Me.OKButton
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.CancelButton = Me.closeButton
Me.ClientSize = New System.Drawing.Size(368, 130)
Me.ControlBox = false
Me.Controls.Add(Me.closeButton)
Me.Controls.Add(Me.OKButton)
Me.Controls.Add(Me.passwordBox)
Me.Controls.Add(Me.passwordLabel)
Me.Controls.Add(Me.userNameBox)
Me.Controls.Add(Me.userNameLabel)
Me.Name = "MyQuerySample"
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
Me.Text = "Remote Connection"
Me.ResumeLayout(false)
End Sub
Public Overloads Shared Function Main() As Integer
Application.Run(New CallWMIMethod)
End Function
Private Sub OKButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OKButton.Click
Try
Dim connection As New ConnectionOptions
connection.Username = userNameBox.Text
connection.Password = passwordBox.Text
connection.Authority = "ntlmdomain:DOMAIN"
Dim scope As New ManagementScope( _
"
[file://\\FullComputerName\root\DEFAULT
\\FullComputerName\root\DEFAULT
]
", connection)
scope.Connect()
Dim classInstance As New ManagementObject(scope, _
New ManagementPath("SystemRestore.SequenceNumber='12'"), _
Nothing)
' Obtain [in] parameters for the method
Dim inParams As ManagementBaseObject = _
classInstance.GetMethodParameters("CreateRestorePoint")
' Add the input parameters.
' Execute the method and obtain the return values.
Dim outParams As ManagementBaseObject = _
classInstance.InvokeMethod("CreateRestorePoint", inParams, Nothing)
' List outParams
Console.WriteLine("Out parameters:")
Console.WriteLine("ReturnValue: {0}", outParams("ReturnValue"))
Close()
Catch err As ManagementException
MessageBox.Show("An error occurred while trying to execute the WMI method: " & err.Message)
Catch unauthorizedErr As System.UnauthorizedAccessException
MessageBox.Show("Connection error (user name or password might be incorrect): " & unauthorizedErr.Message)
End Try
End Sub
Private Sub closeButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles closeButton.Click
troxsa
Messages postés553Date d'inscriptionjeudi 28 novembre 2002StatutMembreDernière intervention 2 octobre 20161 6 juil. 2006 à 14:28
Oups c'est de la version 2003, mais c'est pas tres grave ça fonctionne aussi avec 2005 a toi de mettre ce qu'il y a, a mettre dans le concepteur form et ça roulera sans probleme !