Execute command

Neko

Newcomer
Joined
Dec 14, 2008
Messages
1
I want to execute a command in VB.NET. When I type this command in a dos-window, it works fine. When I execute exactly the same command in VB, it does NOT work.

I can NOT debug because than I get an error (Can't find the command).

When executing the command, I can see a dos-window open and disappear, but it is too fast to see anything.

How do I solve this?

Code:
Dim objProcess As New Process()
objProcess.StartInfo.WorkingDirectory = strCommandoLokatie
objProcess.StartInfo.FileName = strCommando
objProcess.StartInfo.Arguments = txtDatabase.Text & " -u " & txtUser.Text & " -p" & txtPassword.Text & " > " & strOutputLokatie & "\Dump" & txtDatabase.Text & IIf(chkData.Checked, "", "NoData") & ".sql"
objProcess.Start()
objProcess.Dispose()

Arguments = "klapper -u root -p**** > C:\temp\Dumpklapper.sql"
FileName = "MySqlDump.exe"
WorkingDirectory = "C:\Program Files\MySQL\MySQL Server 5.0\bin"

**** is the real pasword when I run.
 
Have you tried using the pause command?

Try writing all your exact commands to a script.bat file and then use your VB Net to call said bat file.
 
Redirect the output using .NET

Redirection using > is a function of the Windows shell interpreter. To get this to work you would need to launch cmd.exe directly (or via a batch file as Nate suggests). A better solution would be to capture the output of the MySqlDump.exe process and write it to a file. The following thread shows how to do this:

Redirect Standard Output of a Process with window hidden? [C# 2002]

Good luck :cool:
 
Back
Top