Vb.net Visual Basic wmic格式错误

Vb.net Visual Basic wmic格式错误,vb.net,formatting,wmic,Vb.net,Formatting,Wmic,每当我将wmic输出从cmd提示符传输到文本文件时,所有内容的格式都是正确的。每当我的应用程序执行相同的操作时(参见下面的代码),我都会得到相同的输出,只是格式不正确。正确的流程是什么?我正在使用visualbasic 我的变量commandListi是输入文本框的任何命令。因此,在本例中,类似WMICCPU的内容可以得到描述 我测试过的所有其他命令都工作正常,只是WMIC命令的格式不正确 这是确切的代码 Imports System.Net.Mail Public Class Form1

每当我将wmic输出从cmd提示符传输到文本文件时,所有内容的格式都是正确的。每当我的应用程序执行相同的操作时(参见下面的代码),我都会得到相同的输出,只是格式不正确。正确的流程是什么?我正在使用visualbasic

我的变量commandListi是输入文本框的任何命令。因此,在本例中,类似WMICCPU的内容可以得到描述

我测试过的所有其他命令都工作正常,只是WMIC命令的格式不正确

这是确切的代码

Imports System.Net.Mail

Public Class Form1

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    Label6.Visible = False

    Me.Visible = False

    Dim s = New SplashScreen1()
    s.Show()
    System.Threading.Thread.Sleep(1200)
    s.Close()

    Me.Visible = True


End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Button1.Visible = False


    If Not String.IsNullOrEmpty(TextBox1.Text) Then
        If Not String.IsNullOrEmpty(TextBox2.Text) Then
            If Not String.IsNullOrEmpty(RichTextBox1.Text) Then

                If (TextBox1.Text = "rbm-") Then

                    If (TextBox2.Text = "081491") Then

                        Dim commandList() As String
                        Dim i As Integer

                        commandList = RichTextBox1.Text.Split(vbLf)

                        For i = LBound(commandList) To UBound(commandList)

                            Dim wsh As Object
                            wsh = CreateObject("WScript.Shell")
                            Dim waitOnReturn As Boolean : waitOnReturn = True
                            Dim windowStyle As Integer : windowStyle = 0
                            Dim errorCode As Integer

                            wsh.Run("cmd /C echo ----------" & (commandList(i)) & "------------ >> output.txt", windowStyle, waitOnReturn)

                            errorCode = wsh.Run("cmd /C " & (commandList(i)) & " >> output.txt", windowStyle, waitOnReturn)

                            If errorCode = 0 Then

                            Else
                                MsgBox((commandList(i)) & " exited with error code " & errorCode & ".")
                            End If



                        Next

                    End If
                End If


                Dim MyMailMessage As New MailMessage()

                MyMailMessage.From = New MailAddress("contact@rawlingsbm.com")

                MyMailMessage.To.Add("rbmcontactapp@gmail.com")

                MyMailMessage.Subject = "RBM Contact Application"
                MyMailMessage.Body = "Person: " & TextBox1.Text & vbCrLf & "Phone: " & TextBox2.Text & vbCrLf & "Message: " & vbCrLf & RichTextBox1.Text


                Dim SMTPServer As New SmtpClient("smtp.gmail.com")
                SMTPServer.Credentials = New System.Net.NetworkCredential("rbmcontactapp", "PASSWORD_GOES_HERE")
                SMTPServer.EnableSsl = True
                SMTPServer.Port = 587

                Try
                    ' SMTPServer.Send(MyMailMessage)
                    MessageBox.Show("Thanks! We've Got the Message and We'll be in touch soon.")
                    Application.Exit()
                Catch ex As SmtpException
                    MessageBox.Show("Ooops. Something isn't working right. Please try again in just a moment.")
                    MessageBox.Show(ex.Message)
                End Try
            Else
                MessageBox.Show("Please fill out all of the form before sending your message. Thanks!")
                Button1.Visible = True
            End If
        Else
            MessageBox.Show("Please fill out all of the form before sending your message. Thanks!")
            Button1.Visible = True
        End If

    Else
        MessageBox.Show("Please fill out all of the form before sending your message. Thanks!")
        Button1.Visible = True
    End If

End Sub

Private Function Split(ByVal commandList As String(), ByVal vbLf As String) As String
    Throw New NotImplementedException
End Function
End Class

你确定这是实际代码吗?我看到了两个主要错误,甚至不必紧张地看:这两个主要错误是什么?wsh=CreateObjectWScript.Shell您没有使用Set,其次您在wsh.Runcmd中有括号…好的。好的,我通过我构建的GUI传递给cmd提示符的不同命令工作得很好。这只是WMIC命令的格式问题。。。您知道我需要检查哪些内容,或者我需要传递哪些wmic参数吗?我找了又找,什么也找不到。谢谢你的帮助。你能不能先用你正在使用的代码更新你的问题,这会给你一个不同的格式,这样我可以在评论之前测试它?