윈도우 포트 프로세스 목록 확인

port × process list in windows
윈도우 포트 프로세스 목록 확인
윈도우 psnetstat
psnetstat.vbs

1 방법[ | ]

2 테스트[ | ]

명령어
cscript//nologo c:\psnetstat.vbs
실행예시
C:\Users\zetawiki>cscript//nologo c:\psnetstat.vbs
Port    PID     CMD
135     760     svchost.exe
445     4       System
3389    428     svchost.exe
5357    4       System
49152   444     wininit.exe
49153   860     svchost.exe
49154   504     lsass.exe
49155   932     svchost.exe
49156   496     services.exe

3 소스코드[ | ]

' http://jmnote.com/wiki/Psnetstat.vbs
' Usage: > cscript//nologo psnetstat.vbs
set fso = createobject("scripting.filesystemobject") 
set sh  = createobject("wscript.shell") 
set oExec = sh.exec ("tasklist") 
do while not oExec.stdout.atendofstream 
	line = oExec.stdout.readline 
	processes = processes & trim(left(line,27)) & "," 
	PIDs = PIDs & trim(mid(line,30,6)) & "," 
loop
PID = split(PIDs,",") 
Process = split(processes,",") 
set oExec = sh.exec ("netstat -ano") 
wscript.echo "Port"&vbtab&"PID"&vbtab&"CMD"
do while not oExec.stdout.atendofstream 
	line = oExec.stdout.readline 
	flag = true
	if mid(line,3,3)<>"TCP" then flag=false
	if mid(line,10,1)<>"0" then flag=false
	if mid(line,56,9)<>"LISTENING" then flag=false
	if flag = true then
		port = trim(mid(line,18,5))
		netpid = trim(mid(line,72))
		for x = 0 to ubound(PID)
	  	if netpid = PID(x) then exit for 
		next
		cmd = "-"
		if x <= ubound(PID) then cmd = Process(x)
		wscript.echo port&vbtab&netpid&vbtab&cmd
	end if
loop

4 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}