Announcement

Collapse
No announcement yet.

.BAT to ping the default gateway

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • .BAT to ping the default gateway

    im am trying to find a way to ping the default gateway.

    is the a variable you can use to discover teh gateway's IP if i dont know it?

    something like:

    Ping %Default Gateway% >> test.txt

    im guessing the is no predefined variable for the gateway so i tried to set the gateway as a temp variable and ping that but it didnt work. (wont show you the code because you will just laugh at my attempt hehehe!

    i hope my question makes sense?

    thanks guys,
    J

  • #2
    Re: .BAT to ping the default gateway

    Lots of good stuff here using WMI:
    http://windowsitpro.com/article/arti...-computer.html
    Tom Jones
    MCT, MCSE (2000:Security & 2003), MCSA:Security & Messaging, MCDBA, MCDST, MCITP(EA, EMA, SA, EDA, ES, CS), MCTS, MCP, Sec+
    PhD, MSc, FIAP, MIITT
    IT Trainer / Consultant
    Ossian Ltd
    Scotland

    ** Remember to give credit where credit is due and leave reputation points where appropriate **

    Comment


    • #3
      Re: .BAT to ping the default gateway

      A sample of what just came to mind first:

      Code:
      @Set title=Pinging the Default Gateway...
      @(color 6A) & (@Title %title%)
      @echo please wait...
      
      ::# Define a temp variable 'DefaultGateway'
      @For /f "tokens=3" %%* in (
         'route.exe print ^|findstr "\<0.0.0.0\>"'
         ) Do @Set "DefaultGateway=%%*"
      
      ::# Redirect output to a textfile
      @> "pingtest.txt" (
        @echo [%Date% %time%] - %title%
        @ping %DefaultGateway%
      )
      @echo Done
      \Rems

      This posting is provided "AS IS" with no warranties, and confers no rights.

      __________________

      ** Remember to give credit where credit's due **
      and leave Reputation Points for meaningful posts

      Comment


      • #4
        Re: .BAT to ping the default gateway

        perfect perfect perfect.
        TY

        Comment

        Working...
        X