0

I am working on a visual studio 2017 Project on C# and i tried to use the code Process Start. But when i tried it the command did not work cmd window opened but it did not write any command on the Window. What can i do ?

private void button2_Click(object sender, EventArgs e)
{
    Process.Start("cmd", "command");
}
sf_
  • 1,138
  • 2
  • 13
  • 28
  • 2
    Define `the command did not work`. _The above code worked fine for me - it opened up a command prompt._ – mjwills Jul 05 '17 at 14:16
  • so it did not applied the command as Like Example Cmd Cmd> command –  Jul 05 '17 at 14:18
  • it did not run the command on the window –  Jul 05 '17 at 14:18
  • im trying to run this command java - cp.\bin\minecraft.jar;.\bin\lwjgl.jar;.\bin\lwjgl_util.jar; -Djava.library.path =.\bin\natives net.minecraft.client.Minecraft –  Jul 05 '17 at 14:21
  • See the link I provided earlier. Or https://stackoverflow.com/a/32124794/34092 . Or https://stackoverflow.com/a/11030976/34092 . – mjwills Jul 05 '17 at 14:22
  • so can you send me the code for it because in the link there is 3 or 4 codes commented by people and you can you give me the right one –  Jul 05 '17 at 14:28
  • If there are multiple commands they can be separated by "&" as shown in my example below. – Derek Jul 05 '17 at 14:29
  • :) Thanks for help dude you helped me alot –  Jul 05 '17 at 14:30

1 Answers1

0
Process.Start("cmd", "/c command & pause");

I added the & pause so you can see the window stay up.

If you don't want the window to show at all.

ProcessStartInfo info = new ProcessStartInfo( "cmd", "/c command" );
info.CreateNoWindow = true;
info.UseShellExecute = false;
Process.Start( info );
Derek
  • 7,615
  • 5
  • 33
  • 58