' *********************************************************************** ' ' NetSHAKER ' ' Copyright(C) 2009 YASKAWA INFORMATION SYSTEMS Corporation ' All Rights Reserved. ' ' **************************************************************************** ' NetSHAKER Red-Mail現地確認ツール main ' ==========+===========================================+========+=========== ' DATE | Comments |Revision| SIGN ' ==========+===========================================+========+=========== ' 2009/09/09| NSK51+ScoolOffice | New |Miura ' ----------+-------------------------------------------+--------+----------- ' 2009/xx/xx| | | ' ----------+-------------------------------------------+--------+----------- ' ' 概要 ' 引数で指定されたIPに対しpingを実行する。 ' pingの実行結果に従い、戻り値を返す。 ' ' 引数 ' 0 : 読み込むIP ***.***.***.*** ' ' 戻り値 ' 0 : 疎通確認 ' 1 : 疎通失敗 ' ' 注意 ' ' ---------------------------------------------------------------------------- rem エラー発生時も処理継続 On Error Resume Next ' ============================================================================ ' 定義 ' ============================================================================ Dim strTargetServer Dim StdOut Dim return rem 戻り値 Dim match rem ping実行結果判定用文字列 match = "(0% loss)" Dim result rem ping 実行結果 ' ============================================================================ ' メイン処理 ' ============================================================================ rem pingターゲットを引数でもらう strTargetServer = WScript.Arguments.Item(0) rem 入力チェック If Trim(strTargetServer) <> "" Then Set objShell = CreateObject("WScript.Shell") rem ping実行 Set objExec = objShell.Exec("ping -n 5 " & strTargetServer) Do While objExec.Status = 0 WScript.Sleep 100 Loop rem 実行結果 strOutput = objExec.StdOut.ReadAll Else rem 入力なし strOutput = "No target was entered." End If rem 出力結果判定 If InStr(strOutput, match) > 0 Then result = "OK" return = 0 Else result = "NG" return = 1 End If rem 実行結果出力 WScript.StdOut.WriteLine "exec command : " & WScript.ScriptName & " " & strTargetServer WScript.StdOut.WriteLine "exec result : " & result WScript.StdOut.WriteLine "exec out:---------------------------------------->" WScript.StdOut.WriteLine strOutput WScript.StdOut.WriteLine "exec out:<----------------------------------------" rem 戻り値 WScript.Quit return