Hi DW

I'm creating an application in VB.Net which is using the command to complete the tasks the reason why I'm doing this on VB.Net is that I have an interface where the user will be able to type in and also choose the prefered options, the vapplication will then send the kesy to the command to perform it so now the problem is that the command shows I want to hide it, let say I have this System.Diagnostics.process.Start("command")
SendKeys.Send("path & "{enter}") now let say I want to hide the command but send keys to it any help? Sorry for not formating the codes I'm using a phone so it doesn't show the options of formating. Or let say I want to copy a file to another file using the command the paths of the file that will be copied will be typed on a textbox and on the other textbox you can type the directory file to copy the file to and when you click the button the command will be executed and be feeded with these instructions while it hiden. Thank you

Recommended Answers

All 4 Replies

Start by having a look here. You can always hide the textbox with the results.

Thanks but i tried it and it produced lot os errors, I dont know how I can go about it. Or perhaps if you can guide me because the With function produce errors.

You declare the process at the class level because you don't want it to go out of scope. You use WithEvents because you want to be able to respond to thge events when the process sends text to StdOut and StdErr.

Private WithEvents MyProcess As Process

My example used delegates because the background process had to write text to the textbox controls. Since you aren't doing that you won't need the delegates. Just declare two strings at the class level and call them something like stdout and stderr. You first create an instance of the process object then set it to CMD.EXE. You want it to be hidden to you set CreateNoWindow to True. You redirect standard input, standard output and standard error because you will be managing those yourself.

MyProcess = New Process

With MyProcess.StartInfo
    .FileName = "CMD.EXE"
    .UseShellExecute = False
    .CreateNoWindow = True
    .RedirectStandardInput = True
    .RedirectStandardOutput = True
    .RedirectStandardError = True
End With

MyProcess.Start()

MyProcess.BeginErrorReadLine()      'start async read on stderr
MyProcess.BeginOutputReadLine()     'start async read on stdout

When you want to execute a command you do

MyProcess.StandardInput.WriteLine(cmd)
MyProcess.StandardInput.Flush()

Thank you will test that and will report back and if it solved my question I will then mark this thread as solved.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.