c# - How to find the port at which the particular service is listening programatically -
i know service name. there option find port number @ service listening?
ps:
netstat -a -n -o give ip, port, pid
while
tasklist /svc /fi "services eq servicename" give, imagename, pid how merge results of both port of particular service.
here's way go:
- use this output of cmd command
- use this split each line substrings
- compare substring service name want, if same. pid of service.
- execute second command. parse it, portnumber
remark: wise compare string in same casing, either uppercase or lowercase strings before comparing
good luck
Comments
Post a Comment