关于Hide Run CMD

时间:2018-11-30 08:06:02

标签: vb.net cmd

我想在vb.net下运行cmd hide,代码为打击:

Dim oProcess1 As New Process()
    Dim oStartInfo1 As New ProcessStartInfo()
    oStartInfo1.Verb = "runas"
    oStartInfo1.FileName = "cmd.exe"
    oStartInfo1.Arguments = " /c exit /b " & szCode & " | echo %=exitcode% "
    'oStartInfo1.CreateNoWindow = True
    'oStartInfo1.WindowStyle = ProcessWindowStyle.Hidden
    oStartInfo1.UseShellExecute = False
    oStartInfo1.RedirectStandardOutput = True
    oProcess1.StartInfo = oStartInfo1
    oProcess1.Start()
    Dim sOutput1 As String
    Using oStreamReader As System.IO.StreamReader = oProcess1.StandardOutput
        sOutput1 = oStreamReader.ReadToEnd()
    End Using

但是当我在CMD下运行时,输出字符串是:%=exitcode%

cmd /c exit /b 1074065420  | echo %=exitcode%

输出为:4004F00C 如何在vb.net下获得正确的结果?

0 个答案:

没有答案