vb.net 下如何获取CMD返回的值?

2022-08-05 社会 183阅读
     Sub Main()
        Dim myProcess As New Process
        Dim startInfo As New ProcessStartInfo("cmd.exe")
        startInfo.Arguments = "/c netsh wlan show networks"
        '获取无线网卡可以搜索到的无线网络信息
        startInfo.UseShellExecute = False
        startInfo.RedirectStandardOutput = True
        startInfo.CreateNoWindow = True
        myProcess.StartInfo = startInfo
        myProcess.Start()
        myProcess.WaitForExit()
        Dim myStreamReader As IO.StreamReader =      myProcess.StandardOutput
        Dim myStr As String = myStreamReader.ReadToEnd
    End Sub

可以参考这个例子

声明:你问我答网所有作品(图文、音视频)均由用户自行上传分享,仅供网友学习交流。若您的权利被侵害,请联系fangmu6661024@163.com