Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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?

 

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.

Posted

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.

~Nate�

___________________________________________

Please use the [vb]/[cs] tags on posted code.

Please post solutions you find somewhere else.

Follow me on Twitter here.

Posted

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:

Never trouble another for what you can do for yourself.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...