c# - 我试图从 c# windows 应用程序打开命令行以运行 exe 文件,但它只打开 cmd 而没有运行命令
问题描述
这是我试图打开命令行的代码。我想要做的是运行命令`“client_server.exe”+ received_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();
推荐阅读
- php - 如何实现两个php mysql查询并在两个表中显示?
- dotnetnuke - 将 DNN 9.0.1 升级到 9.2 在 PersonaBar 失败
- java - 元音开头的名词 vs 不带元音的名词
- reactjs - 按下改变颜色:将类转换为函数
- python - 在我的计算机上使用 Docker 在本地安装 KoboToolbox 的正确方法是什么?
- c# - LINQ - 对连接表进行分组和求和
- unity3d - 出于某种原因,我在对象的检查器部分看不到覆盖选项
- video - 转换失败。关闭 ffmpeg 时队列中剩余 2 帧
- javascript - 您可以使用变量,但也可以在闭包中本地重新声明它吗?
- css - ClojureScript 中未显示 CSS 属性