执行命令提示符 [英] To perform the command prompt
本文介绍了执行命令提示符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我将如何通过编码执行Net View命令提示符,以将所有计算机名称从LAN收集到字符串数组中????
任何人都可以为我解决上述问题...
How will i execute the Net View command prompt through coding to collect the all machine name into string array from LAN?????
anybody Please help me for above problem......
推荐答案
尝试代码:
Hi, try the code:
Function ComputerList() As String()
Dim p As New Process
Dim sysFolder As String = Environment.GetFolderPath(Environment.SpecialFolder.System)
p.StartInfo.FileName = System.IO.Path.Combine(sysFolder, "net.exe")
p.StartInfo.Arguments = "view"
p.StartInfo.UseShellExecute = False
p.StartInfo.RedirectStandardOutput = True
p.Start()
Dim result As String = p.StandardOutput.ReadToEnd
p.WaitForExit()
Dim mList As New List(Of String)
For Each line As String In result.Split(vbLf)
If line.Length > 2 AndAlso line.Substring(0, 2) = "\\" Then
mList.Add(line.Split(" ")(0).Replace("\\", String.Empty))
End If
Next
Return mList.ToArray
End Function
这篇关于执行命令提示符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文