본문 바로가기
VB.net

x86, x64 모두 사용 가능한 cmd

by 호야호잇 2021. 3. 31.
        Dim result_Cmd As New RichTextBox

        Dim output As String
        Dim ptr As IntPtr = New IntPtr()
        Wow64DisableWow64FsRedirection(ptr)
        Dim info As ProcessStartInfo = New ProcessStartInfo()
        Dim proc As Process = New Process()

        With info
            .RedirectStandardOutput = True
            .UseShellExecute = False
            .FileName = "cmd.exe"
            .Arguments = "/c query session /vm"
        End With

        proc.StartInfo = info
        proc.Start()
        output = proc.StandardOutput.ReadToEnd
        proc.WaitForExit()
        Wow64RevertWow64FsRedirection(ptr)

        result_Cmd.Text = output