0

So im trying to make a ip pinger to see if a server is online and have got this so far i would like it so that the user can in put a ip on there own from a text box. but keep getting a error on the start part.

Error CS1501 No overload for method 'Start' takes 3 arguments

System.Diagnostics.Process.Start ("cmd", "/k ping"  + flatTextBox1.Text ,"-t");
Dumbo
  • 13,555
  • 54
  • 184
  • 288
Waypast
  • 65
  • 1
  • 1
  • 9
  • The error is pretty clear. You aren't matching any of the [valid signatures for `System.Diagnostics.Process.Start`](https://msdn.microsoft.com/en-us/library/system.diagnostics.process.start(v=vs.110).aspx). – dirn Jan 26 '16 at 22:57

2 Answers2

1

I see several issues here:

First, the "-t" is used as third parameter because of the comma before it. You should add it to the string you're building with "/k" in combination with the IP address.

Next, given the textbox text is "127.0.0.1" this will currently end up as: /k ping127.0.0.1

So you might just add a space in between the "ping" and the IP.

BUT: you should not use cmd.exe for this, consider to use the Ping class from the .NET framework.

Waescher
  • 5,361
  • 3
  • 34
  • 51
  • Very helpful I was aiming for a user to input a ip address into the text box then lunch the cmd with a button and automatically write a line saying "ping 127.0.0.0 -t" would that work ? – Waypast Jan 26 '16 at 22:43
  • Yes it will, just use your code line: `Process.Start("cmd", "/k ping 127.0.0.1 -t");` – Waescher Jan 26 '16 at 22:45
  • But where abouts would I need to put the +flat text.Text so that it dosnt give me a error – Waypast Jan 26 '16 at 22:48
  • `Process.Start("cmd", "/k ping " + flatTextBox1.Text + " -t");` – Waescher Jan 26 '16 at 22:49
  • Now the question is, can you get any info back into your program if you are able to start the ping as a process? As stated in the edited answer, maybe you should look at the ping class in the .NET framework if your goal is to check to see if a server is online. – AndrewK Jan 27 '16 at 14:36
  • You mean to read the stdout of that process, I think. Take a look here: http://stackoverflow.com/questions/206323/how-to-execute-command-line-in-c-get-std-out-results – Waescher Jan 27 '16 at 14:39
1

Try using ProcessStartInfo:

ProcessStartInfo startInfo = new ProcessStartInfo("cmd");
startInfo.Arguments = "/k ping " + flatTextBox1.Text + " -t";
Process.Start(startInfo);
AndrewK
  • 1,223
  • 2
  • 16
  • 25