This batch of processing is a half original bar, which borrowed from the Baidu library inside a statistic of Windows directory and file number of batch processing, has been online on the system, using the VBS script file to invoke, statistical function is normal.
@Echo off
set/a a=0
Netstat-an | find/i "Port" > list File Save path
for/f "delims="%%a in (' Type list file save path ') do set/a a+=1
@Echo on
echo "%date%%time%----%a%"
Here is a brief explanation:
set/a a=0 defines a variable and assigns the variable here, if the variable is not assigned here, there will be a number of cumulative problems in the following statistics;
Netstat-an | The role of find/i "Port" is to locate the corresponding port in the information of the netstat command output and redirect the information to a file for easy use later
The "delims=" command is a command to set the cutting point of a Windows cutting string, such as a string that is Asadafag, then the string is then outputted with the Delims=a command, which becomes the S D F G, as in awk.
For xx%%a in (' xx ') doing xx this is the batch process inside for loop;
@Echo off/on is the screen output that turns on and off Echo, because the batch process outputs the assignment results directly when assigning a value to the variable, so you can turn off the screen output when you assign it, but you want to open it later, in order to save the results.