sgilmour Posted December 31, 2008 Posted December 31, 2008 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.ThanksScottIpconfig.vbsdoSet objShell = CreateObject("WScript.Shell")Set objWshScriptExec = objShell.Exec("ipconfig /all")Set objStdOut = objWshScriptExec.StdOut'' Skip first three lines'strLine = objStdOut.ReadLineWScript.Echo strLinestrLine = objStdOut.ReadLineWScript.Echo strLinestrLine = objStdOut.ReadLineWScript.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 strLineWendwscript.sleep 10000Loopping.vbsSet 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.StdOutDo Until objStdOut.AtEndOfStream strLine = objStdOut.ReadLine If Len(strLine) > 2 Then WScript.Echo Now & " -- " & strLine Else Wscript.Echo strLine End IfLoop
CoffeeFiend Posted December 31, 2008 Posted December 31, 2008 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.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now