public class BlackWindow

{

private static BlackWindow _instance;

public static BlackWindow Instance

{

get

{

if (_instance == null)

_instance = new BlackWindow();

return _instance;

}

}

public System.Diagnostics.Process pro { set; get; }

BlackWindow()

{

//下面StartInfo的UseShellExecute和RedirectStandardInput/Output选项为互斥选项

//若设置UseShellExecute=true代表使用dos黑窗口,但RedirectStandardInput/Output必须为false,表示输入输出也只能通过dos窗口手工录入,不能通过StandardInput.WriteLine输入

//若要显示Dos窗口,但又想通过程序输入命令,只能用StartInfo.Arguments = cmdLine;但该参数只能输入一行

//StartInfo.Arguments命令前一定要加/k表示打开新窗口,否则运行结果无法显示

pro = new System.Diagnostics.Process();

pro.StartInfo.FileName = "cmd.exe";

//pro.StartInfo.UseShellExecute = false; //true代表使用dos窗口,默认true

//pro.StartInfo.RedirectStandardInput = true;

// pro.StartInfo.RedirectStandardOutput = true;

//pro.StartInfo.CreateNoWindow = true;

}

public void Start(string cmdLine)

{

pro.StartInfo.Arguments = cmdLine;

pro.StartInfo.WorkingDirectory = "";//工作目录

pro.Start();

//pro.StandardInput.WriteLine(cmdLine);

pro.WaitForExit();

pro.Close();

}

}

用Dos黑窗口运行Cmd命令的更多相关文章

  1. C#隐式运行CMD命令(隐藏命令窗口)

    原文 C#隐式运行CMD命令(隐藏命令窗口) 本文实现了C#隐式运行CMD命令的功能.下图是实例程序的主画面.在命令文本框输入DOS命令,点击"Run"按钮,在下面的文本框中输出运 ...

  2. [delphi]运行cmd命令,并取得输出字符

     http://blog.csdn.net/nerdy/article/details/8969189 [delphi]运行cmd命令,并取得输出字符 标签: delphiCMD命令 2013-05- ...

  3. ASP.NET CORE下运行CMD命令

    ASP.NET CORE下运行CMD命令,用以前的ASP.NET 的命令System.Diagnostics.Process.Start("notepad");这样是可以运行出记事 ...

  4. C# 运行CMD命令

    /// <summary> /// 运行CMD命令 /// </summary> /// <param name="cmd">命令</pa ...

  5. Atitit.运行cmd 命令行 php

    Atitit.运行cmd 命令行 php 1. 运行cmd 命令行,调用系统命令的基础 1 1.1. 实际运行模式 1 1.2. 空格的问题 1 1.3. 中文路径的问题.程序文件读取编码设置 1 1 ...

  6. C#中隐式运行CMD命令行窗口的方法

    using System; using System.Diagnostics; namespace Business { /// <summary> /// Command 的摘要说明. ...

  7. java运行cmd命令

    java的Runtime.getRuntime().exec(commandStr)可以调用执行cmd指令. cmd /c dir 是执行完dir命令后关闭命令窗口. cmd /k dir 是执行完d ...

  8. Windows学习总结(12)——Windows 10系统开始运行-cmd命令大全

    gpedit.msc-----组策略 sndrec32-------录音机 Nslookup-------IP地址侦测器 explorer-------打开资源管理器 logoff---------注 ...

  9. ECStore在Win环境下如何运行CMD命令

    大多数程序员使用windows开发环境来做ECStore二次开发,经常需要使用 ECStore自带的cmd命令进行一些系统操作,如清除缓存(cacheclean),升级程序(update),创建新的a ...

随机推荐

  1. android多国语言使用

    多国语言:在res目录下建立不同名称的values文件来调用不同的语言包 Values文件汇总如下: 中文(中国):values-zh-rCN 中文(台湾):values-zh-rTW 中文(香港): ...

  2. LeetCode OJ:Add Digits(数字相加)

    Given a non-negative integer num, repeatedly add all its digits until the result has only one digit. ...

  3. L142

    keep half an eye on something分神留意splash out随意花钱 大肆挥霍half a mind有想做某事go Dutch v. 各自付帐,打平伙chance in a ...

  4. New Concept English three (42)

    21 33 Cave exploration, or pot-holing, as it has come to be known, is a relatively new sport. Perhap ...

  5. 【python】windows下安装xgboost的python库

    傻瓜教程 主要参考了https://www.hongweipeng.com/index.php/archives/826/  和 https://github.com/dmlc/xgboost/iss ...

  6. 谈谈Java基础数据类型

    Java的基本数据类型 类型 意义 取值 boolean 布尔值 true或false byte 8位有符号整型 -128~127 short 16位有符号整型 -pow(2,15)~pow(2,15 ...

  7. CentOS7 编译安装golang和rpm安装golang

    编译安装 1.下载golang二进制安装包: https://storage.googleapis.com/golang/go1.9.linux-amd64.tar.gz 2.解压安装包到指定目录,此 ...

  8. mono developer 无法启动 可以试试如下插件包.

    http://download.xamarin.com/GTKforWindows/Windows/gtk-sharp-2.12.22.msi 我以前装的旧版unity 再装了新的版本以后 mono ...

  9. 人生苦短之我用Python篇(安装第三方库、正则表达式)

    安装第三方库 两种方法, 一.在DOS界面下运行 pip3 install requests 二.切换至request目录下 cd E:\ python3 setup.py install ----- ...

  10. 使用 event.preventDefault 拦截表单的提交

    event.preventDefault() 方法 W3C 官方的定义是:取消事件的默认动作,不单单可以拦截表单的提交,<a>标签的跳转, <input>标签的输入等等默认动作 ...