Results 1 to 2 of 2

Thread: [RESOLVED] Open command prompt and see command run from App

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337

    Resolved [RESOLVED] Open command prompt and see command run from App

    Hi guys/gals,

    I have a small problem that when I open cmd.exe and send commands to it I see the command prompt open and the command runs but I don't see any text in the window. when the command finishes I get the result in a rich text box. How can I see the code run in the command window? some commands can take a long time so I want to know that something is going on.

    Code:
     Dim CmdString As String = ""
    
            If RadioBtnApply.Checked = True Then
                CmdString = "dism /apply-image /imagefile:" & TxtImageFile.Text & " /index:1 /applydir:C:\"
            ElseIf RadioBtnCapture.Checked = True Then
                CmdString = "dism /Capture-Image /ImageFile:" & TxtImageFile.Text & " /CaptureDir:C:\ /name:""" & OS & """ /compress:fast"
    
            ElseIf RadioBtnDiskpart.Checked = True Then
                CmdString = "diskpart /s diskpartcmds.txt"
            End If
            ' MsgBox(CmdString)
            p.StartInfo.FileName = "cmd.exe"
            ' p.StartInfo.Arguments = " /K " ' /C runs string then exits, /K runs string then stays
            ' p.StartInfo.CreateNoWindow = True 'True to hide the console window
            p.StartInfo.UseShellExecute = False 'must have set
            p.StartInfo.RedirectStandardOutput = True 'must have set
            p.StartInfo.RedirectStandardInput = True
            p.EnableRaisingEvents = True 'used to receive the Process`s Exited event
            p.Start()
            'p.StandardInput.WriteLine(CmdString)
    
            Dim SR As System.IO.StreamReader = p.StandardOutput
            Dim SW As System.IO.StreamWriter = p.StandardInput
            SW.WriteLine("Applying Image")
            SW.WriteLine(CmdString) 'the command you wish to run.....
            'SW.WriteLine("exit") 'exits command prompt window
            RichTextBox1.Text = SR.ReadToEnd 'returns results of the command window
            SW.Close()
            SR.Close()

  2. #2

    Thread Starter
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337

    Re: Open command prompt and see command run from App

    Never mind, I think creating the batch file will be easier.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width