• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 165
  • Last Modified:

Script or command to ping active nic gateway

I have an application that displays a system tray icon that can reference a command or a script for troubleshooting steps for end users. Pinging the default gateway is a step I would like to add without customizing each application installation for each clients network. Any ideas?
0
emconsulting
Asked:
emconsulting
  • 2
1 Solution
 
QlemoC++ DeveloperCommented:
Something simple:
@echo off
setlocal EnableDelayedExpansion
set IP=
FOR /F "tokens=2 delims=:" %%a IN ('ipconfig ^| findstr /IC:"Default Gateway"') DO (
  if NOT "%%a" == " " ping %%a -n 1
)
exit /b

Open in new window

0
 
emconsultingAuthor Commented:
Thank you. I need the results do display to the user. What would I add to the code? I also saved this as a .bat file, is that correct?
0
 
QlemoC++ DeveloperCommented:
.bat or .cmd does not matter, though I prefer latter.
You probably just need the script to pause until a key is pressed to allow for viewing the result. Replace the exit /b with pause.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now