'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