博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
C# 执行bat文件并取得回显
阅读量:4598 次
发布时间:2019-06-09

本文共 639 字,大约阅读时间需要 2 分钟。

using System.IO;using System.Diagnostics;ProcessStartInfo pro = new System.Diagnostics.ProcessStartInfo("cmd.exe");pro.UseShellExecute = false;pro.RedirectStandardOutput = true;pro.RedirectStandardError = true;pro.CreateNoWindow = true;pro.Arguments = "/K " + System.Environment.CurrentDirectory + @"\net_create.bat";pro.WorkingDirectory = System.Environment.CurrentDirectory;System.Diagnostics.Process proc = System.Diagnostics.Process.Start(pro);System.IO.StreamReader sOut = proc.StandardOutput;proc.Close();string results = sOut.ReadToEnd().Trim(); //回显内容sOut.Close();

转载于:https://www.cnblogs.com/whisht/archive/2012/10/27/3085077.html

你可能感兴趣的文章
CSS3.0——背景属性
查看>>
【转载】C语言中的undefined behavior/unspecified behavior - 序
查看>>
MySQL服务使用
查看>>
C语言练手自己编写学生成绩管理系统
查看>>
20175204 张湲祯 2018-2019-2《Java程序设计》第二周学习总结
查看>>
NCPC 2015 - Problem A - Adjoin the Networks
查看>>
How to lisp Lisp output a paragraph"500 Tph Dry Process Cement Plant Machinery Manufacturers"
查看>>
Unix系统编程()文件描述符和打开文件之间的关系
查看>>
OpenMobile's Application Compatibility Layer (ACL)
查看>>
html中文件类型的accept属性有哪些
查看>>
JS及JQuery对Html内容编码,Html转义
查看>>
Coursera公开课笔记: 斯坦福大学机器学习第十课“应用机器学习的建议(Advice for applying machine learning)”...
查看>>
竞价广告系统-广告检索
查看>>
强哥PHP面向对象学习笔记
查看>>
[转]基于.NET平台常用的框架整理
查看>>
Symbian (Read Inbox)读取收件箱的内容
查看>>
良好的编程规范
查看>>
struts2 入门
查看>>
.net 编译原理
查看>>
mean 快速开发和现有技术的对比分析
查看>>