Question Issues Running Command Prompt from Program - Help!

Hoho5000

Member
Joined
Oct 17, 2009
Messages
5
Programming Experience
1-3
I'm working on a program that relies on another program to convert some data. This other program is a command line executable. The code I'm using is as follows.

VB.NET:
        Using m_process As New Process()
            With m_process.StartInfo
                .FileName = "cmd.exe"
                .UseShellExecute = False
                .RedirectStandardInput = True
                .CreateNoWindow = True
            End With

            m_process.Start()
            For Each file As FileInfo in folder
                 m_process.StandardInput.WriteLine("somecommand")
            Next

            m_process.Close()
        End Using

That should work, but the input to the command line never gets processed because as soon as the process is started, it ends. Setting to CreateNoWindow to false shows the command prompt opening for a split second and then closing, even though the operation should take at least several seconds. Scouring the internet reveals no clue as to why this is happening. If I set UseShellExecute to true, the window stays open, but I can't redirect input that way. This is really frustrating.

Can anyone offer some insight as to why this is happening?
 
Last edited:
Because I need to run several commands within one window. That way, several hundred command prompts don't open at the same time and cause the system to hang.
 
This might help: [ame=http://www.vbforums.com/showthread.php?t=381405]Automate Command Prompt Window (CMD), Redirect Output to Application [2003/2005] - VBForums[/ame]
 
Back
Top