May be it help
Local $port
If $CmdLine[0] == 0 Then
MsgBox(0x0,"Err","arg is empty")
Exit 1
Else
$port = $CmdLine[1]
EndIf
Func _MyPortExists($port)
Local $sRead, $sBuffer, $CMD_PId
$CMD_PId = Run(@ComSpec & ' /c netstat -an | find "UDP" | find ":' & $port & ' " /C', "C:\", @SW_HIDE, 0x2)
While 1
$sBuffer = StdoutRead($CMD_PId)
If @error Then ExitLoop
If $sBuffer Then
$sRead &= $sBuffer
EndIf
Sleep(2)
WEnd
$sRead = StringLeft ( $sRead, 1 )
If $sRead == 0 Or $sRead == 1 Or $sRead == 2 Then
Return $sRead
Else
;~ _Log_MyInfo( $flog, $sRead & ", " & VarGetType($sRead) & ", -->" & $sRead & "<--")
Return _MyPortExists($port)
EndIf
EndFunc
If _MyPortExists($port) <> 0 Then
MsgBox(0x0,"PortLst","Open")
Else
MsgBox(0x0,"PortLst","Closed")
EndIf