How to execute cmd command in C#

zian0217 1 Reputation point
2022-12-11T04:44:35.07+00:00

this is my cmd command and i want to execute this in C# using visual studio
start game.exe ur;name=server;ip=192.168.148.129;port=8888

i tried this but its not working
gameExe = Path.Combine(rootPath, "game.exe ur;name=server;ip=192.168.148.129;port=8888");

Developer technologies C#
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Abdulhakim M. Elrhumi 356 Reputation points
    2022-12-11T07:24:27.893+00:00

    Hi
    ProcessStartInfo psi = new ProcessStartInfo();
    psi.FileName = "apktool";
    //gameExe = Path.Combine(rootPath, "game.exe ur;name=server;ip=192.168.148.129;port=8888");

    //join the arguments with a space, this allows you to set "app.apk" to a variable
    psi.Arguments = String.Join(" ", "d", "app.apk");

    //leave it to the application, not the OS to launch the file
    psi.UseShellExecute = false;

    //choose to not create a window
    psi.CreateNoWindow = true;

    //set the window's style to 'hidden'
    psi.WindowStyle = ProcessWindowStyle.Hidden;

    var proc = new Process();
    proc.StartInfo = psi;
    proc.Start();
    proc.WaitForExit();

    Best regards.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.