useshellexecute在C#中,那条语句是可以控制关机的?

useshellexecute  时间:2021-05-19  阅读:()

c#关机程序

Process myProcess = new Process();//定义一个线程实例; myProcess.StartInfo.FileName = "cmd.exe";//启动名为"cmd.exe"的线程,就相当于你点击电脑左下角的"开机"-"运行"-输入cmd后回车,也就是启动了命令提示符界面; myProcess.StartInfo.UseShellExecute = false;//关闭Shell的使用 myProcess.StartInfo.RedirectStandardInput = true;//重定向标准输入 myProcess.StartInfo.RedirectStandardOutput = true;//重定向标准输出 myProcess.StartInfo.RedirectStandardError = true;//重定向错误输出 myProcess.StartInfo.CreateNoWindow = true;//设置不显示窗口 myProcess.Start();//此处才是启动了该线程 myProcess.StandardInput.WriteLine("shutdown -s -t 0");//相当于你在命令提示符界面输入"shutdown -s -t 0",只不过不显示窗口界面。

"shutdown -s -t 0"是电脑关机指令,你可以百度下

用C#怎么通过进程打开qq——博客园

Process process = new Process(); process.StartInfo.UseShellExecute = false; process.StartInfo.CreateNoWindow = true; process.StartInfo.FileName = “QQ”; process.Start();

这个关机程序是什么意思?

呵呵,这是创建一个进程运行cmd.exe然后设置运行状态,最后开始进程输入命令"shutdown -s -t 60". 这是运行Windows 里的命令提示符来实现的.你可以按住Windows+R来打开命令提示符输入shutdown -s -t 60回车也可以关机.

如何用C#执行DOS命令

using System.IO; using System.IO.Compression; Process p = null; p = new Process(); p.StartInfo.FileName = "cmd.exe"; p.StartInfo.UseShellExecute = false; p.StartInfo.RedirectStandardInput = true; p.StartInfo.RedirectStandardOutput = true; p.StartInfo.RedirectStandardError = true; p.StartInfo.CreateNoWindow = true; p.Start(); strOutput="doc命令"; p.StandardInput.WriteLine(strOutput); p.StandardInput.WriteLine("exit"); while (p.StandardOutput.EndOfStream) { strOutput = p.StandardOutput.ReadLine(); Console.WriteLine(strOutput); } p.WaitForExit(); p.Close();

在C#中,那条语句是可以控制关机的?

正好我以前没事的时候写着玩过一个.... using System.Diagnostics; //别忘了引这个命名空间 private static void QuXiaoGuanJi() //这个是取消关机的方法 { Process p = new Process(); p.StartInfo.FileName = "cmd.exe"; p.StartInfo.UseShellExecute = false; p.StartInfo.RedirectStandardInput = true; p.StartInfo.RedirectStandardOutput = true; p.StartInfo.CreateNoWindow = true; p.Start(); p.StandardInput.WriteLine("shutdown -a"); p.StandardInput.WriteLine("exit"); } private static void GuanJi() //这个是关机的方法 { Process p = new Process(); p.StartInfo.FileName = "cmd.exe"; p.StartInfo.UseShellExecute = false; p.StartInfo.RedirectStandardInput = true; p.StartInfo.RedirectStandardOutput = true; p.StartInfo.CreateNoWindow = true; p.Start(); p.StandardInput.WriteLine("shutdown -s -t 90"); p.StandardInput.WriteLine("exit"); } private void btnQueDing_Click(object sender, EventArgs e) //这是按钮的事件 { if (txtInput.Text == "我是猪") { this.lblMessage.Text = "这样才对嘛....嘿嘿 爽!"; this.Refresh(); QuXiaoGuanJi(); Thread.Sleep(1000); Application.Exit(); } else { this.lblMessage.Text = "快点说哦~~ 时间不等人啊~~"; } }

易探云(QQ音乐绿钻)北京/深圳云服务器8核8G10M带宽低至1332.07元/年起

易探云怎么样?易探云香港云服务器比较有优势,他家香港BGP+CN2口碑不错,速度也很稳定。尤其是今年他们动作很大,推出的香港云服务器有4个可用区价格低至18元起,试用过一个月的用户基本会续费,如果年付的话还可以享受8.5折或秒杀价格。今天,云服务器网(yuntue.com)小编推荐一下易探云国内云服务器优惠活动,北京和深圳这二个机房的云服务器2核2G5M带宽低至330.66元/年,还有高配云服务器...

DogYun香港BGP月付14.4元主机简单测试

前些天赵容分享过DogYun(狗云)香港BGP线路AMD 5950X经典低价云服务器的信息(点击查看),刚好账户还有点余额够开个最低配,所以手贱尝试下,这些贴上简单测试信息,方便大家参考。官方网站:www.dogyun.com主机配置我搞的是最低款优惠后14.4元/月的,配置单核,512MB内存,10GB硬盘,300GB/50Mbps月流量。基本信息DogYun的VPS主机管理集成在会员中心,包括...

SunthyCloud阿里云国际版分销商注册教程,即可PayPal信用卡分销商服务器

阿里云国际版注册认证教程-免绑卡-免实名买服务器安全、便宜、可靠、良心,支持人民币充值,提供代理折扣简介SunthyCloud成立于2015年,是阿里云国际版正规战略级渠道商,也是阿里云国际版最大的分销商,专业为全球企业客户提供阿里云国际版开户注册、认证、充值等服务,通过SunthyCloud开通阿里云国际版只需要一个邮箱,不需要PayPal信用卡就可以帮你开通、充值、新购、续费阿里云国际版,服务...

useshellexecute为你推荐
dota启动项dota2启动选项怎么设置fps国外服务器加速为什么很多外国游戏国内需要加速器才能玩?免费服务器资源免费资源赞助 免费赞助服务器 带宽 www.22w.com服务器硬防专家你好,我想租一个免备案+硬防的服务器。硬防大概要30G左右 有便宜又好用的推荐吗?谢谢拉快云服务器快云的云服务器好用吗?好看的表格样式创意怎样使用excel制作漂亮的表格127美元127万人民币等多少美元国外虚拟服务器怎样把自己的网页放到国外的虚拟服务器中Godaddy?香港云服务器推荐香港服务器怎么样?哪个比较好啊?服务器租用免费为什么租用服务器啊,自己免费在网上注册一个个人网站不行吗
xenvps enzu bandwagonhost 512au 网页背景图片 新站长网 网站木马检测工具 服务器合租 789 免费ftp 双线空间 创速 存储服务器 windowsserver2008r2 机柜尺寸 时间同步服务器 一句话木马 赵荣博客 瓦工工具 什么是云主机 更多