如何实现远程执行了一个dos命令,并把结果返回显示在一个listbox上
我现在使用的是WMI连接,这是代码,命令也已经在远程执行了,但是我怎么获取到这个命令的结果,并且把所有命令的结果显示在listbox上呢?
Dim options As New ConnectionOption
Dim _scope as ManagementScope
options.Username = “aaa“
options.Password = "aaaa"
options.Authority = "ntlmdomain:strdomain"
If strdomain Is Nothing Then
_scope = New ManagementScope("\\" 10.0.0.1 "\root\cimv2", options)
_scope.Connect()
Else
options.Authority = "ntlmdomain:strdomain"
_scope = New ManagementScope("\\" 10.0.0.1 "\root\cimv2", options)
_scope.Connect()
End If
Dim o As New ObjectGetOptions()
Dim path As ManagementPath = New ManagementPath("Win32_Process")
Dim processClass As ManagementClass = New ManagementClass(_scope, path, o)
Dim inParams As ManagementBaseObject = processClass.GetMethodParameters("Create")
Dim a As ManagementObject
Dim b As String
b = Nothing
inParams("CommandLine") = "cmd.exe /c netstat -an"