进程开始不工作Cmd窗口C# [英] Process Start Wont Work Cmd Window C#

查看:69
本文介绍了进程开始不工作Cmd窗口C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在C#上的Visual Studio 2017项目中工作,我试图使用代码Process Start.但是,当我尝试执行该命令时,命令打开的cmd窗口不起作用,但没有在窗口上写入任何命令.我该怎么办?

I am working on a visual studio 2017 Project on C# and i tried to use the code Process Start. But when i tried it the command did not work cmd window opened but it did not write any command on the Window. What can i do ?

private void button2_Click(object sender, EventArgs e)
{
    Process.Start("cmd", "command");
}

推荐答案

Process.Start("cmd", "/c command & pause");

我添加了&暂停,这样您就可以看到窗口停滞了.

I added the & pause so you can see the window stay up.

如果您根本不希望窗口显示.

If you don't want the window to show at all.

ProcessStartInfo info = new ProcessStartInfo( "cmd", "/c command" );
info.CreateNoWindow = true;
info.UseShellExecute = false;
Process.Start( info );

这篇关于进程开始不工作Cmd窗口C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆