vb.net Code:
  1. Dim p As New Process
  2.         Dim pi As New ProcessStartInfo
  3.         pi.UseShellExecute = False
  4.         pi.RedirectStandardOutput = True
  5.         pi.WorkingDirectory = "C:\windows\system32"
  6.         'this for nt* computers
  7.         pi.FileName = "diskpart.exe"
  8.         p.StartInfo = pi
  9.         p.Start()
  10.         Dim sr As IO.StreamReader = p.StandardOutput
  11.         Dim sb As New System.Text.StringBuilder("list disk")
  12.         Dim input As Integer = sr.Read
  13.         Do Until input = -1
  14.             sb.Append(ChrW(input))
  15.             input = sr.Read
  16.         Loop
  17.         RichTextBox1.Text = (sb.ToString)

This is what I have so far as code. I am trying to create a GUI for the Disk Partition Console. Reason being that if you go to format a hard drive, you may have to use the console if you have to perform an override. I was working on a computer last week where I had to wipe the entire hard drive and it wouldn't let me do so with disk management. So I am trying to create a simple GUI for the diskpart.exe console. I have seen people make simulated console applications. However, with diskpart.exe, its been difficult. There are not a lot of related topics on google or on any forums sites that can help me. I have tried basing it off the way its done with CMD, but have been struggling. I am trying to just get the two programs to communicate I/O and display all the output in a richtextbox. Any tips? this is the code I have managed to come up with. I have had many other codes that all have failed such as:

vb.net Code:
  1. Dim prcDOS As New Process
  2.         Dim siDOS As New ProcessStartInfo
  3.  
  4.         siDOS.FileName = "cmd"
  5.  
  6.         siDOS.UseShellExecute = False
  7.         siDOS.CreateNoWindow = True
  8.         siDOS.RedirectStandardInput = True
  9.         siDOS.RedirectStandardOutput = True
  10.  
  11.         prcDOS.StartInfo = siDOS
  12.         prcDOS.Start()
  13.  
  14.         Dim srInput As StreamWriter = prcDOS.StandardInput
  15.         Dim srOutput As StreamReader = prcDOS.StandardOutput
  16.  
  17.         srInput.WriteLine("diskpart.exe")
  18.  
  19.         srInput.WriteLine("list drive")
  20.  
  21.         srInput.WriteLine("exit")
  22.  
  23.         strResults = srOutput.ReadToEnd
  24.  
  25.  
  26.  
  27.         srInput.Close()
  28.         srOutput.Close()
  29.  
  30.         Invoke(ShowText)

AND

vb.net Code:
  1. Dim p As Process = Process.Start("diskpart.exe")
  2.         'AppActivate(p.MainWindowTitle)
  3.         System.Threading.Thread.Sleep(100)
  4.         My.Computer.Keyboard.SendKeys("list disk", True)
  5.  
  6.         My.Computer.Keyboard.SendKeys("{ENTER}", True)

This last code, I knew it was not a logical idea so I stopped and never even tried finishing that attempt.