Stopping netstat.exe after one display?


  1. Posts : 149
    Windows 7 Ultimate x64
       #1

    Stopping netstat.exe after one display?


    "netstat /?" says:

    "interval Redisplays selected statistics, pausing interval seconds
    between each display. Press CTRL+C to stop redisplaying
    statistics. If omitted, netstat will print the current
    configuration information once."

    On my system, it keeps running displaying connections as they are established. What is that "If omitted" referring to?

    Is there a way to get a snapshot without having to use Ctrl+C to quit netstat.exe?
      My Computer


  2. Posts : 721
    Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
       #2

    So by running netstat on its own, the command will display your current TCP/IP network connections and protocol statistics ONCE.

    By running
    Code:
    netstat <SomePositiveNonzeroIntegerValueHere>
    you are telling the netstat command to output your network connections and protocol statistics indefinitely. Once the command has finished displaying all statistics, it'll wait <SomePositiveNonzeroIntegerValueHere> seconds before repeating the netstat command again.

    So running netstat 4 is kind of like running the batch script
    Code:
    @echo off
    :top
    netstat
    timeout 4 >NUL
    goto :top

    swiftie said:
    Is there a way to get a snapshot without having to use Ctrl+C to quit netstat.exe?
    I'm not so sure what you mean by snapshot?
      My Computer


  3. Posts : 149
    Windows 7 Ultimate x64
    Thread Starter
       #3

    The bit that I'm struggling with is the "once". If I run "netstat -a -b" then I get a list of connections, but then netstat keeps running, adding new connections to the end of the list.

    So, in order for netstat to terminate, I always have to Ctrl+C it.

    It just seems a little odd, having to use Ctrl+C regardless of the parameters used. It's no big deal though, just a curiosity.
      My Computer


  4. Posts : 6,285
    Windows 10 Pro X64
       #4

    Does the same for me on my Win 8 Pro X64 system and Win 7 Pro X64 system.
      My Computer


  5. Posts : 721
    Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
       #5

    I don't understand. I'm not sure what I'm supposed to be answering here.

    swiftie said:
    The bit that I'm struggling with is the "once". If I run "netstat -a -b" then I get a list of connections, but then netstat keeps running
    ...
    So, in order for netstat to terminate, I always have to Ctrl+C it.
    Are you saying that the output of the command netstat -a -b is infinity ongoing? It isn't. With a stopwatch in hand, for me, it takes just over 30 seconds at its quickest and 2 minutes at its longest for the command netstat -a -b to complete. Depending on how connection involved your machine is, the Net Status command can take a while to execute.


    The title of this thread questions how one would go about halting the execution of a command after one cmd screen full of display. To answer that, you'd pipe to more.
    E.g.
    Code:
    netstat | more
      My Computer


  6. Posts : 6,285
    Windows 10 Pro X64
       #6

    Guess I didn't wait long enough. Took 39 seconds for me.
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 23:59.
Find Us