Domanda

I am trying to open a simple log.txt file (in this example comandos.txt) after running a netstat command like so:

@ 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. Any clues on how to solve this?

È stato utile?

Soluzione

@ 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. 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. Show some message like Collecting information... or similar.

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top