[英]How to open a .txt file after using netstat command with Batch
I am trying to open a simple log.txt file (in this example comandos.txt) after running a netstat command like so: 我试图像这样运行netstat命令后打开一个简单的log.txt文件(在本示例中为comandos.txt):
@ echo off
echo. >> C:\comandos.txt
netstat -b -o 1 >> C:\comandos.txt
start C:\comandos.txt
After netstat Prompt Windows won't close and comandos.txt won't open. 在netstat提示Windows之后,Windows将不会关闭,并且comandos.txt将不会打开。 Any clues on how to solve this?
关于如何解决这个问题的任何线索?
@ echo off
echo. >> C:\comandos.txt
netstat -b -o >> C:\comandos.txt
start C:\comandos.txt
The above snippet works fine. 上面的代码片段效果很好。 Note that you were specifying the
interval
in netstat
command which redisplays the statistics again and again. 请注意,您在
netstat
命令中指定了interval
,该interval
一次又一次地显示统计信息。 Also, because you have echo
turned off
and display redirected to the file, the empty prompt window showing up for a long time would send wrong signals. 另外,由于您已
off
echo
并将显示重定向到文件,因此长时间显示的空白提示窗口将发送错误的信号。 Show some message like Collecting information...
or similar. 显示一些诸如
Collecting information...
类的消息。
Also, given that the command needs to resolve addresses and depends on the number of processes with network connection, it may take some time for netstat
to complete which would be system dependent. 同样,鉴于命令需要解析地址并且取决于具有网络连接的进程数,
netstat
可能需要一些时间才能完成,这取决于系统。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.