How can I hide command prompt in a VB program but also take an action?

197 Views Asked by At

I am creating a program that will format flash drives selected by the user. I am doing this by using the format.com process. The issue with hiding the command prompt window is command prompt requires you to hit enter in order to begin the format of the drive. Is there a way to bypass this? Also, is there anyway VB can tell when command prompt has finished so I can create a message that says the formatting is finished? My relevant code is below.

For j = 0 To drives.Length() - 1
            Dim formatProcess As New ProcessStartInfo("format.com", drives(j) & "/Q /FS:NTFS /V:" & formattedDate)
            formatProcess.WindowStyle = ProcessWindowStyle.Hidden
            formatProcess.CreateNoWindow = True
            Process.Start(formatProcess)
        Next
1

There are 1 best solutions below

4
On BEST ANSWER

Instead of hiding it, you can force a press of the enter key immediately (and then possibly hide it).

You can do this:

SendKeys.Send("{ENTER}")

As for sensing when it is done:

Is there a process that shows up while it is formatting? If so, you can check for this process and display the message when the process isn't there.