TCPポート接続確認ツール

WindowsXP以降&Windows2003以降のOSでコマンドプロンプトにて

netsh diag connect iphost 任意のIPアドレス 任意のポート番号

を使用すると、任意のIPアドレスの任意のポートへ到達できるか確認できる(TCPのみ)。
とはいっても、コマンドラインが長すぎる気がするので、ラップするGUIhtaで作成してみた。コピペして、拡張子.htaで保存すれば使用できます。

<html><head>
<title>ポート開通テストツールforWindowsXP/Windows2003</title></head>
<body>
<form name="form1">
ポート接続のテストを行います。<BR>
WindowsXP以上およびWindows2003以上で使用可能です。
    <p>IPアドレスまたはサーバー名 
    <input type="text" name="ipaddr" value="127.0.0.1" /></p>
    <p>ポート番号 
    <input type="text" name="portno" value="80" /></p>
    <p><input type="button" value="ポート開通テスト 実行"
        onClick="porttest()" /></p>
    <textarea name="kekka" cols="80" rows="12"></textarea>
</form>
<script language="VBScript">
    Dim WshShell, oExec
    Set WshShell = CreateObject("WScript.Shell")
	
    Sub Window_onLoad()
        window.resizeTo 650,450
    End Sub 

    Sub porttest()
        exCommand = "netsh diag connect iphost " & document.form1.ipaddr.value & " " & document.form1.portno.value 
        Set oExec = WshShell.Exec(exCommand)
        
        RetPort = oExec.Stdout.ReadAll
        document.form1.kekka.value = RetPort & "                                              ↑ここの値が[なし]なら接続失敗" & chr(13) & "                                              [" & document.form1.portno.value & "]なら成功です"
    End Sub
</script>
</body></html>