Échec de l'Utilisation de Cdm.exe +commande avec Vb.net
Dans une feuille j'ai un bouton initulé « Scanner » qui déclenche la commande
"Sfc /scannow" par l'intermédiaire d'un process. J'utilise un sous-programme "RunCommand"
trouvé sur le Net.
Cette procédure fonctionne parfaitement avec l'utilitaire Dism /OnLine.... Mais pour exécuter
la commande Sfc /scannow il y a blocage avec le message « La Protection des Ressources n' pas
réussi à démarrer le service de réparation bien que je sois en Administrateur.
Voir image Cmd.jpg ci-joint
Si quelqu'un a une idée - Merci de vos réponses.
Code:
1 2 3
| Private Sub Scan_Click(sender As Object, e As EventArgs) Handles Scan.Click ' Scanne l'intégrité avec Sfc.exe /scannow
MyUtilities.RunCommandCom("Sfc", "/Scannow", True)
End Sub |
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| Public Class MyUtilities
Shared Sub RunCommandCom(command As String, arguments As String, permanent As Boolean)
Try
Dim p As New Process()
Dim pi As New ProcessStartInfo With {
.Arguments = " " + If(permanent = True, "/K", "/C") + " " + command + " " + arguments,
.FileName = "cmd.exe"
}
p.StartInfo = pi
p.Start()
p.Close()
Catch Ex As Exception
MsgBox(Ex.Message)
End Try
End Sub
End Class |