Set Ws=CreateObject("WScript.Shell")
Set oExec=ws.Exec("%comspec% /c netstat -an -p TCP")
s=oExec.StdOut.ReadAll
wscript.echo re(s)
function re(a)
set regex=new regexp
regex.pattern=":[1-9][\d]{1,4}"
regex.global=true
set matchs=regex.execute(a)
for each match in matchs
m=replace(match,":","")
if instr(re,m)=0 then
re=re & m & vbcrlf
end if
next
end function