掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
EXEからDOSコマンドを実行、結果(DOSプロンプトに表示される内容)を取得するには (ID:114925)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
Pingが目的なら、WMI の Ping Provider を使って、 Dim Searcher As New Management.ManagementObjectSearcher( _ "SELECT * FROM Win32_PingStatus WHERE Address='192.168.0.3'") For Each Mng As Management.ManagementObject In Searcher.Get() Dim U As UInt32 = CType(Mng("StatusCode"), UInt32) If U.Equals(U.Parse("0")) Then MessageBox.Show("Success") ElseIf U.Equals(U.Parse("11010")) Then MessageBox.Show("Request Timed Out") Else MessageBox.Show("その他のエラー") End If Next Searcher.Dispose() とか。 標準出力の取得が目的であれば、Processクラスを使って、 Dim p As New Process With p.StartInfo .WindowStyle = ProcessWindowStyle.Normal .FileName = "PING" .Arguments = "192.168.0.3" .RedirectStandardOutput = True .UseShellExecute = False End With p.Start() p.WaitForExit(1000) Trace.WriteLine(p.StandardOutput.ReadToEnd()) p.Dispose() とか。
←解決時は質問者本人がここをチェックしてください。
戻る
掲示板システム
Copyright 2020 Takeshi Okamoto All Rights Reserved.