Capture and return stdout in c#

Drew

Client
Регистрация
29.07.2012
Сообщения
70
Благодарностей
14
Баллы
8
I am trying to run netstat for a specific PID and would like to return output from cmd into ZP.

Has anyone done this in c#?

For example I would like to run
netstat -no | findstr "8723"

And return the output to a ZP variable.
 
Последнее редактирование:

Radzhab

Client
Регистрация
23.05.2014
Сообщения
1 500
Благодарностей
1 263
Баллы
113
I found alternative solution. Add to using
using System.Net;
using System.Net.NetworkInformation;

and this code to snippet
C#:
IPGlobalProperties ipProperties = IPGlobalProperties.GetIPGlobalProperties();
IPEndPoint[] endPoints = ipProperties.GetActiveTcpListeners();
TcpConnectionInformation[] tcpConnections = ipProperties.GetActiveTcpConnections();

foreach (TcpConnectionInformation info in tcpConnections)
            {
                var localAdress = info.LocalEndPoint.Address.ToString();
                var remoteAdress = info.RemoteEndPoint.ToString();
                var state = info.State.ToString();
                var pid = info.LocalEndPoint.Port.ToString();
                if (pid=="8723")
                    {
                         ......
                    }
            }
 

Кто просматривает тему: (Всего: 1, Пользователи: 0, Гости: 1)