IP-Auslesen Batch Einzeiler in VBS
Hi nichts großes bin ein totaler Newbie in VB-Script...
Könnte mir jemand diesen Einzeiler in VBS schreiben?
for /f "skip=1 tokens=2 delims=" %%* in ('ping.exe -n 1 -4 %computername%') Do (set "IP=%%*")
Danke schon mal im Vorraus
Schönes Wochenende
ZeXoRs
Könnte mir jemand diesen Einzeiler in VBS schreiben?
for /f "skip=1 tokens=2 delims=" %%* in ('ping.exe -n 1 -4 %computername%') Do (set "IP=%%*")
Danke schon mal im Vorraus
Schönes Wochenende
ZeXoRs
Please also mark the comments that contributed to the solution of the article
Content-Key: 187592
Url: https://administrator.de/contentid/187592
Printed on: April 25, 2024 at 03:04 o'clock
8 Comments
Latest comment
Hallo
In etwa so:
Gruß Dieter
In etwa so:
Dim sComputer, sStdOut, sIP
With CreateObject("WScript.Shell")
sComputer = .Environment("Process").Item("Computername")
sStdOut = .Exec("Ping -n 1 -4 " & sComputer).StdOut.ReadAll
End With
If InStr(sStdOut, "[") > 0 Then
sIP = Split(Split(sStdOut, "[", 2)(1), "]")(0)
Else
sIP = "Nothing"
End If
MsgBox sIP
Gruß Dieter
Hallo ZeXoRs!
Die Frage ist, wie das Format des Ersetzen-Textes aussehen soll, also "p000000e0" ersetzen durch was? "Computername...? IP...?"
Gruß Dieter
Die Frage ist, wie das Format des Ersetzen-Textes aussehen soll, also "p000000e0" ersetzen durch was? "Computername...? IP...?"
Gruß Dieter
Hallo Zexi!
Das Ganze, dann so:
Gruß Dieter
Das Ganze, dann so:
Const strFilename = "C:\DATEV\PROGRAMM\DATEVDMS\program.ini"
Dim objFso, strText, strComputer, strStdOut, strIP
With CreateObject("WScript.Shell")
strComputer = .Environment("Process").Item("Computername")
strStdOut = .Exec("Ping -n 1 -4 " & strComputer).StdOut.ReadAll
End With
strIP = ""
If InStr(strStdOut, "[") > 0 Then
strIP = Split(Split(strStdOut, "[", 2)(1), "]")(0)
End If
Set objFso = CreateObject("Scripting.FileSystemObject")
With objFso.OpenTextFile(strFilename)
strText = Replace(.ReadAll, Chr(34), "")
.Close
End With
strText = Replace(strText, "p000000e0", strComputer, 1, -1, vbTextCompare)
strText = Replace(strText, "xxx.xxx.xxx.xx", strIP)
With objFso.CreateTextFile(strFilename)
.Write strText
.Close
End With
Gruß Dieter
Hallo Zusammen.
Ist zwar gelöst, aber warum in einem VBScript die Kommandozeile bemühen?
Nur mal so ...
Grüße
rubberman
Ist zwar gelöst, aber warum in einem VBScript die Kommandozeile bemühen?
Nur mal so ...
Set colNetAdp = GetObject("winmgmts:!\\.\root\cimv2").ExecQuery( _
"Select * from Win32_NetworkAdapterConfiguration Where IPEnabled=True")
For Each oNetAdp In colNetAdp
WScript.Echo oNetAdp.IPAddress(0)
Next
Grüße
rubberman
Hallo rubberman!
Gruß Dieter
Ist zwar gelöst, aber warum in einem VBScript die Kommandozeile bemühen?
Hätte es ja auch gerne ohne die Cmd gelöst, aber Dein Lösungsweg war mir nicht bekannt bzw. ist mir entfallenGruß Dieter