How I can execute a Batch Command in C# directly?

后端 未结 2 1093
名媛妹妹
名媛妹妹 2021-01-04 13:31

I want to execute a batch command and save the output in a string, but I can only execute the file and am not able to save the content in a string.

Batch file:

2条回答
  •  忘掉有多难
    2021-01-04 14:27

    Don't need to use "CMD.exe" for execute a commandline application or retreive the output, you can use "lmxendutil.exe" directly.

    Try this:

    processInfo = new ProcessStartInfo();
    processInfo.FileName  = "C:\\lmxendutil.exe";
    processInfo.Arguments = "-licstatxml -host serv005 -port 6200";
    //etc...
    

    Do your modifications to use "command" there.

    I hope this helps.

提交回复
热议问题