Stopping netstat.exe after one display?

swiftie

Old git Member
Member
VIP
Local time
12:13 PM
Messages
149
Location
Hampshire, England
"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 My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Arbico/Quiet i7377
OS
Windows 7 Ultimate x64
CPU
3.40 gigahertz Intel Core i7-3770 Multi-core (4 total)
Motherboard
ASUSTeK COMPUTER INC. P8Z77-V LX Rev X.0x
Memory
16Gb
Graphics Card(s)
AMD Radeon HD 7700
Sound Card
AMD High Definition Audio Device
Monitor(s) Displays
Samsung 2443BW/Lenovo L2240pwD
Screen Resolution
1920x1200 1050x1680
Hard Drives
OCZ-VERTEX450 (256 GB)
ST31000524AS (1000.20 GB)
Drobo 5D 5-disk enclosure
Seagate USB 1Tb
ST1500DL 003-9VT16L 1500.30 GB
Case
Special noise-reducing case
Cooling
Quiet fans
Keyboard
Lenovo SK-8815 Multimedia keyboard
Mouse
Logitech MX
Internet Speed
~7mbps
Antivirus
Microsoft Security Essentials (and caution)
Browser
Chrome/Opera/Firefox/IE/Off-by-One
Other Info
Acoustic Energy AEGO-M Speakers - incredible sound, given their size.
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 [COLOR="Red"]<SomePositiveNonzeroIntegerValueHere>[/COLOR]
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


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 My Computer

Computer type
PC/Desktop
OS
Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
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 My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Arbico/Quiet i7377
OS
Windows 7 Ultimate x64
CPU
3.40 gigahertz Intel Core i7-3770 Multi-core (4 total)
Motherboard
ASUSTeK COMPUTER INC. P8Z77-V LX Rev X.0x
Memory
16Gb
Graphics Card(s)
AMD Radeon HD 7700
Sound Card
AMD High Definition Audio Device
Monitor(s) Displays
Samsung 2443BW/Lenovo L2240pwD
Screen Resolution
1920x1200 1050x1680
Hard Drives
OCZ-VERTEX450 (256 GB)
ST31000524AS (1000.20 GB)
Drobo 5D 5-disk enclosure
Seagate USB 1Tb
ST1500DL 003-9VT16L 1500.30 GB
Case
Special noise-reducing case
Cooling
Quiet fans
Keyboard
Lenovo SK-8815 Multimedia keyboard
Mouse
Logitech MX
Internet Speed
~7mbps
Antivirus
Microsoft Security Essentials (and caution)
Browser
Chrome/Opera/Firefox/IE/Off-by-One
Other Info
Acoustic Energy AEGO-M Speakers - incredible sound, given their size.
Does the same for me on my Win 8 Pro X64 system and Win 7 Pro X64 system.
 

My Computer My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Lenovo IdeaCenter 450
OS
Windows 10 Pro X64
CPU
Intel Quad Core i7-4770 @ 3.4Ghz
Memory
16.0GB PC3-12800 DDR3 SDRAM 1600 MHz
Graphics Card(s)
Intel Integrated HD Graphics
Sound Card
Realtek HD Audio
Monitor(s) Displays
HP 22" LCD
Screen Resolution
1680 x 1050
Hard Drives
250GB Samsung EVO SATA-3 SSD
2TB Seagate ST2000DM001 SATA-2
1.5TB Seagate ST3150041AS SATA
Keyboard
Dell USB
Mouse
Lenovo USB
Internet Speed
Cable via Road Runner 3MB Upload, 30MB Download
Antivirus
Windows Defender, MBAM Pro, MBAE
Browser
Seamonkey
Other Info
UEFI/GPT
PLDS DVD-RW DH16AERSH
I don't understand. I'm not sure what I'm supposed to be answering here.

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 My Computer

Computer type
PC/Desktop
OS
Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
Guess I didn't wait long enough. Took 39 seconds for me.
 

My Computer My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Lenovo IdeaCenter 450
OS
Windows 10 Pro X64
CPU
Intel Quad Core i7-4770 @ 3.4Ghz
Memory
16.0GB PC3-12800 DDR3 SDRAM 1600 MHz
Graphics Card(s)
Intel Integrated HD Graphics
Sound Card
Realtek HD Audio
Monitor(s) Displays
HP 22" LCD
Screen Resolution
1680 x 1050
Hard Drives
250GB Samsung EVO SATA-3 SSD
2TB Seagate ST2000DM001 SATA-2
1.5TB Seagate ST3150041AS SATA
Keyboard
Dell USB
Mouse
Lenovo USB
Internet Speed
Cable via Road Runner 3MB Upload, 30MB Download
Antivirus
Windows Defender, MBAM Pro, MBAE
Browser
Seamonkey
Other Info
UEFI/GPT
PLDS DVD-RW DH16AERSH
Back
Top