'v2.5*************************************************** ' File: ip-dresse.VBS ' Autor: dieseyer@gmx.de ' dieseyer.de ' ' Programm ermittelt den PC-Name und alle IP-Adressen '******************************************************* ' Option Explicit ' Siehe http://dieseyer.de/dse-wsh-lernen.html#OptionExpl Set WSHShell = WScript.CreateObject("WScript.Shell") Set FSO = CreateObject("Scripting.FileSystemObject") Set WSHNet = WScript.CreateObject("WScript.Network") Ziel = "winipcfg.out" Set Env = WSHShell.Environment("PROCESS") if Env("OS") = "Windows_NT" then WSHShell.run "%comspec% /c ipconfig > " & Ziel, 0, True ' ipconfig nach Ziel umleiten else WSHShell.run "winipcfg /batch" ,0 ,True ' winipcfg /batch legt autom. "winipcfg.out" an end if set WSHShell = nothing Set FileIn = fso.OpenTextFile(Ziel, 1 ) ' Datei zum Lesen öffnen TextX = FileIn.ReadAll ' alles lesen FileIn.Close Set FileIn = nothing if fso.FileExists(Ziel) Then fso.DeleteFile(Ziel), True ' Datei löschen TextX = Split(TextX, vbCRLF) ' alles gelesene in Zeilen aufteilen AllIPadr = "Dieser Computer heißt " & wshnet.ComputerName & vbCRLF AllIPadr = AllIPadr & "und hat folgende IP-Adresse(n): " & vbCRLF & vbCRLF for i1 = 0 to ubound(TextX) ' jede Zeile überprüfen if InStr(UCase(TextX(i1)), "IP-ADRESSE") then ' enthält die akt. Zeile ... IPadr = "" IPadr = Mid(TextX(i1), InStr(UCase(TextX(i1)), ": ") + 1) ' alles rechts vom ": " IPadr = trim(IPadr) If IPadr <> "" Then AllIPadr = AllIPadr + IPadr ' alle IP-Adr. ' If IPadr <> "" Then Exit For ' nur erste IP-Adr. End If next MsgBox AllIPadr, ,WScript.ScriptName