I've seen similar examples, but can't find something exactly like my problem.
I need to run a command like this from C#:
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = "cmd";
startInfo.Arguments = "/K D:\\as df\\solver\\Swag.Console.exe -f D:\\as df\\solver\\2035.swag -p 5555";
Process.Start(startInfo);
does not work.
startInfo.Arguments = "/K \"D:\\as df\\solver\\Swag.Console.exe\" -f D:\\as df\\solver\\2035.swag -p 5555";
does not work.
startInfo.Arguments = "/K \"D:\\as df\\solver\\Swag.Console.exe\" -f \"D:\\as df\\solver\\2035.swag\" -p 5555";
does not work.
startInfo.FileName = "\"D:\\as df\\solver\\Swag.Console.exe\"";
startInfo.Arguments = " -f \"D:\\as df\\solver\\2035.swag\" -p 5555";
so it works, but I want to CMD, is this possible?
The /K argument will execute the command that follows it. It can be a whole lot of commands chained with & but, and this is what you were missing in your attempts, they need to be fully enclosed in double quotes in that case. See the SS64 cmd reference
In other words, the command should look like this:
Because of the forward and backslashes you quickly lose track. So I took out the outer double quotes wrapping a String.Format, so it becomes a bit more clear what your actual command should be like. Here is the code that I expect should work:
If Swag.Console.Exe would simply dump its arguments to the console this would be the outcome: