Jump to content

Recommended Posts

Posted

I have an ipconfig script and I am editing so it will run for one minute every ten seconds then I am looking to be able to add a ping script to the end of the ipconfig and ping 4 different default gateways. Does anybody know how this can be done. I haven't found a ping script that I can just enter the ip addresses of the default gateways I want to ping (199.169.20.1, 10.1.180.1, 20.1.180.1 and 192.168.1.1) Here is my ipconfig script and what I have so far for a ping script but it is not working.

Any help or suggestions would be appreciated.

Thanks

Scott

Ipconfig.vbs

do

Set objShell = CreateObject("WScript.Shell")

Set objWshScriptExec = objShell.Exec("ipconfig /all")

Set objStdOut = objWshScriptExec.StdOut

'

' Skip first three lines

'

strLine = objStdOut.ReadLine

WScript.Echo strLine

strLine = objStdOut.ReadLine

WScript.Echo strLine

strLine = objStdOut.ReadLine

WScript.Echo strLine

'

' Add date/time information

'

strCurrentTime = " Current Date/Time. . . . . . . . .: " & Now()

WScript.Echo strCurrentTime

'

' Display the rest of the output

'

While Not objStdOut.AtEndOfStream

strLine = objStdOut.ReadLine

WScript.Echo strLine

Wend

wscript.sleep 10000

Loop

ping.vbs

Set objShell = CreateObject("WScript.Shell")

Set objWshScriptExec = objShell.Exec("ping 10.1.180.1")

Set objWshScriptExec = objShell.Exec("ping 192.168.1.1")

Set objWshScriptExec = objShell.Exec("ping 190.169.20.1")

Set objWshScriptExec = objShell.Exec("ping 10.1.40.1")

Set objStdOut = objWshScriptExec.StdOut

Do Until objStdOut.AtEndOfStream

strLine = objStdOut.ReadLine

If Len(strLine) > 2 Then

WScript.Echo Now & " -- " & strLine

Else

Wscript.Echo strLine

End If

Loop


Posted

No need to use the ipconfig or ping executables to do any of this, nor having to parse the text from their output and such.

Look at the Win32_PingStatus and Win32_NetworkAdapterConfiguration WMI classes (fully documented on MSDN). Everything you need is right there.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...