C#自我总结: 运行DOS命令如何隐藏DOS界面
2012-01-23 01:37
926 查看
这也是杀掉桌面进程explorer.exe而不自启的唯一方法,例如:Projects.DOS.cmd("taskkill /f /im explorer.exe"),不信你试一试!利用timer控件可轻易禁用taskmgr.exe。
作者:(⊙_⊙)★燚♂靈惢★空间
出处:http://515847999.qzone.qq.com
CSDN个人主页:http://hi.csdn.net/qq515847999
本文版权归作者和广大编程爱好者共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利……
using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
namespace Projects
{
class DOS
{
public static string cmd(String command) //向cmd()传入命令行,传入"exit"则退出cmd.exe。
{
Process p = new Process();
p.StartInfo.FileName = "cmd.exe";
p.StartInfo.UseShellExecute = false; //这里是关键点,不用Shell启动
p.StartInfo.RedirectStandardInput = true; //重定向输入
p.StartInfo.RedirectStandardOutput = true; //重定向输出
p.StartInfo.CreateNoWindow = true; //不显示窗口
p.Start();
p.StandardInput.WriteLine(command);// 向cmd.exe输入command
//p.WaitForExit();
p.StandardInput.WriteLine("exit");
string s = p.StandardOutput.ReadToEnd();// 得到cmd.exe的输出
p.Close();
return s;
}
}
}
作者:(⊙_⊙)★燚♂靈惢★空间
出处:http://515847999.qzone.qq.com
CSDN个人主页:http://hi.csdn.net/qq515847999
本文版权归作者和广大编程爱好者共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利……
using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
namespace Projects
{
class DOS
{
public static string cmd(String command) //向cmd()传入命令行,传入"exit"则退出cmd.exe。
{
Process p = new Process();
p.StartInfo.FileName = "cmd.exe";
p.StartInfo.UseShellExecute = false; //这里是关键点,不用Shell启动
p.StartInfo.RedirectStandardInput = true; //重定向输入
p.StartInfo.RedirectStandardOutput = true; //重定向输出
p.StartInfo.CreateNoWindow = true; //不显示窗口
p.Start();
p.StandardInput.WriteLine(command);// 向cmd.exe输入command
//p.WaitForExit();
p.StandardInput.WriteLine("exit");
string s = p.StandardOutput.ReadToEnd();// 得到cmd.exe的输出
p.Close();
return s;
}
}
}
相关文章推荐
- C#中运行DOS命令隐藏DOS界面
- 如何让基于对话框的程序运行时隐藏界面
- 如何“隐藏”运行程序的“命令提示符”界面(C代码)
- 2017/12/23Java基础学习——如何通过记事本编写代码,并通过dos界面运行Java源文件
- 当在程序中运行DOS命令时如何隐藏DOS窗口并判断其结束
- vc 写win32控制台程序时如何隐藏自身的dos界面
- 如何在android手机上实现app开机自动运行启动(可以打开应用界面)。
- 让MFC程序隐藏运行界面
- 如何在Windows系统上运行编写的java文件_更新dos命令设置path
- 如何在Windows XP中运行DOS程序
- win7如何在登陆界面隐藏一个账户
- java界面运行出来后如何让其显示在屏幕中间
- 隐藏MFC 运行界面的绝佳方案
- 如何隐藏Win7登录界面的administrator用户名-E时代-中国公众科技网
- 如何让主界面NavigationBar隐藏,而push到的下一个界面显示NavigationBar?
- [自我总结]如何使用VS2005中的OLEDB的JET SQL驱动来动态创建数据表!
- Android如何保持程序一直运行 (让屏幕常亮且停在当前程序界面)
- 如何提高自我的人格魅力,提升职场竟争力的小小总结。
- MFC对话框初始化运行时如何隐藏,托盘图标,任务栏图标的相关问题
- 如何在 Dos 下运行 PHP 和 MySQL 命令