Commande tracert,ping,ipconfig

pitufo2804

XLDnaute Junior
Bonjour a tous,
j'effectue un petit soft avec excel avec quelques outils du genre ping,tracert,ipconfig,shutdown,...
tout marche a merveille sauf que lorsque je lance le ping ou le tracert, la fenetre dos s'ouvre et se ferme apres la requete ping et instentanement pour le tracert et l'ipconfig.
comment fait on pour les laisser ouvertes ?!
merci !
 
Dernière édition:

julberto

XLDnaute Occasionnel
Re : Commande tracert,ping,ipconfig

Bonjour pitufo2804,


La solution est de rediriger le log de sortie vers un fichier et de le reprendre avec Excel.
C'est mon avis, mais bon....

Un code trouvé par là sur internet qui illustre ce propos. Je ne l'ai pas testé, pas plus qu'épluché. Je te le soumet quand même.

Code:
'Afficher l'ipconfig dans excel
Sub getIPConfig()
    Sheets("Feuil1").Select
    Range("A5").Select
    Dim objShell As Object
    Dim intFile As Integer, intRow As Integer, intColumn As Integer
    Dim strCurrentLine As String
    Set objShell = CreateObject("Wscript.Shell")
    objShell.Run ("%comspec% /c ipconfig /all > C:\ipcfg.txt")
    Set objShell = Nothing
    Application.Wait Now + 0.00003
    intFile = FreeFile
    intRow = ActiveCell.Row
    intColumn = ActiveCell.Column
    Open "C:\ipcfg.txt" For Input As #intFile
    Do
      Line Input #intFile, strCurrentLine
      Select Case Len(strCurrentLine)
        Case 0
          intRow = intRow - 1
        Case Is < 43
          Cells(intRow, intColumn) = strCurrentLine
        Case Else
          Cells(intRow, intColumn + 1) = Mid(strCurrentLine, 8, 26)
          Cells(intRow, intColumn + 2) = Mid(strCurrentLine, 45)
      End Select
      intRow = intRow + 1
    Loop Until EOF(intFile)
    Close #intFile
    Kill "C:\ipcfg.txt"
    Set objShell = Nothing
End Sub
cordialement
 

Statistiques des forums

Discussions
312 492
Messages
2 088 936
Membres
103 987
dernier inscrit
Doctami