lunedì 19 febbraio 2018

vba excel esegue ipconfig e scrive sul foglio gli indirizzi ip

 

'

Option Explicit

'

Dim riga

'

' esegue ipconfig e scrive sul foglio excel gli indirizzi ip.

' gli antivirus tendono a bloccare una simile operazione.

'

Sub leggilineadicomando()

Dim objShell, objExecObject, strLine, strIP

Set objShell = CreateObject("WScript.Shell")

Set objExecObject = objShell.Exec("%comspec% /c ipconfig.exe")

 

Do Until objExecObject.StdOut.AtEndOfStream

 strLine = objExecObject.StdOut.ReadLine()

 strIP = InStr(strLine, "Address")

' If strIP <> 0 Then

    'Wscript.Echo strLine

    riga = riga + 1

    ActiveSheet.Cells(riga, 1).Value = strLine

' End If

Loop

'

End Sub

Nessun commento:

Posta un commento