Is it possible to traceroute a host, but only get error text if tracing fails?
Q: tracert.exe command always returns a bunch of text. How can I ignore it if trace finished successfully?
A: The trick is to store entire traceroute (tracert.exe) output, parse it and only return text if typical errors indicators (words) have been detected.
Please download archive traceroute-host.zip from our scripts library.
Inside, you will find file traceroute-host.txt and “readme” file with installation instructions. At the moment, we assume you have created folder C:\scripts and unpacked the mentioned file there.
After you unpack it, rename traceroute-host.txt to traceroute-host.vbs.
Now open IPNetwork Monitor GUI client and create Script or Program monitor. At stage 3 of monitor creation wizard, enter script location and specify command-line arguments:

Note that this script takes single argument: host name to trace. Google.com is chosen for the sake of example.
Switch to State conditions tab, and create Down state condition: it only should return zero in case of success; any other value means error (Down state):

Click on “Finish” to conclude and start the monitor. In the example above, google.com is periodically traced. Note: change hops number (in the script: parameter “-h” passed to tracert.exe, on line 11), if tracing takes more than 5 hops. Note that every hop means up to 2 additional seconds of waiting (parameter “-w” passed to tracert.exe), thus too many hops cap can cause the entire script to time out.
Note: if you wish to modify the script, use cscript utility to debug it. Open cmd.exe, and issue commands:
c: cd C:\scripts cscript //nologo traceroute-host.vbs google.com
to imitate the script behavior as in the example above. Note: use actual folder name you keep the script in.
Check out our Knowledge Base where we answer questions regarding various topics. Capture the full tracert.exe output in a script, check it for known error indicators, and return text only when a failure is detected. The script takes one argument: the host name to trace. Use the real target host instead of the sample google.com value. Run it with cscript from a command prompt before relying on the monitor. This shows the same output and return behavior IPNetwork Monitor will receive.
Frequently Asked Questions
How can successful traceroute output be hidden?
What argument does the traceroute script use?
How should changes to the traceroute script be tested?