Eric Perryman
Eric Perryman

Reputation: 11

How can I use a TextBox Value as an argument for a ping cmd

I can get the ping to work, I'm having trouble figuring out how to pass the value of a text box as an argument so I can ping the value from the text box. Can someone point me in the right direction?

Process test = new Process();
test.StartInfo.FileName = "ping";
test.StartInfo.UseShellExecute = false;
test.StartInfo.Arguments = "www.google.com";
test.StartInfo.RedirectStandardOutput = true;
test.Start();
textBox1.Text = test.StandardOutput.ReadToEnd();

Upvotes: 1

Views: 398

Answers (1)

user5151179
user5151179

Reputation: 585

Change test.StartInfo.Arguments = "www.google.com"; to test.StartInfo.Arguments = textBox1.Text;, assuming that textBox1 is the text box you're interested in.

Upvotes: 1

Related Questions