簡體   English   中英

我試圖從C#Windows應用程序打開命令行以運行exe文件,但它僅打開cmd而不運行命令

[英]Im trying to open a command line from c# windows application in order to run an exe file but its only opening the cmd and not running the command

這是我嘗試使用命令行打開的代碼。 我想做的是運行命令`“ client_server.exe” + receive_ip; 在cmd中,但是它僅打開窗口而不運行命令。 有人對我有解決方案嗎?

var process = new Process();
                    var startInfo = new ProcessStartInfo();
                    //startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
                    startInfo.FileName = "cmd.exe";
                    startInfo.Arguments = @"client_server.exe " + received_ip;
                    process.StartInfo = startInfo;
                    process.Start();

                    process.WaitForExit();

您是否嘗試過UseShellExecute屬性?

var process = new Process();
var startInfo = new ProcessStartInfo();

startInfo.FileName = "client_server.exe";
startInfo.Arguments = received_ip;

startInfo.UseShellExecute = true;

process.StartInfo = startInfo;
process.Start();

process.WaitForExit();

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM