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 = "快点说哦~~ 时间不等人啊~~"; } }

香港2GB内存DIYVM2核(¥50月)香港沙田CN2云服务器

DiyVM 香港沙田机房,也是采用的CN2优化线路,目前也有入手且在使用中,我个人感觉如果中文业务需要用到的话虽然日本机房也是CN2,但是线路的稳定性不如香港机房,所以我们在这篇文章中亲测看看香港机房,然后对比之前看到的日本机房。香港机房的配置信息。CPU内存 硬盘带宽IP价格购买地址2核2G50G2M1¥50/月选择方案4核4G60G3M1¥100/月选择方案4核8G70G3M4¥200/月选择...

特网云(198元/月),高质量云虚拟主机低至0.16元/天,裸金属服务器仅需10.5元/天

特网云为您提供高速、稳定、安全、弹性的云计算服务计算、存储、监控、安全,完善的云产品满足您的一切所需,深耕云计算领域10余年;我们拥有前沿的核心技术,始终致力于为政府机构、企业组织和个人开发者提供稳定、安全、可靠、高性价比的云计算产品与服务。官方网站:https://www.56dr.com/ 10年老品牌 值得信赖 有需要的请联系======================特网云推出多IP云主机...

香港云服务器最便宜价格是多少钱一个月、一年?

香港云服务器最便宜价格是多少钱一个月/一年?无论香港云服务器推出什么类型的配置和活动,价格都会一直吸引我们,那么就来说说香港最便宜的云服务器类型和香港最低的云服务器价格吧。香港云服务器最便宜最低价的价格是多少?香港云服务器只是服务器中最受欢迎的产品。香港云服务器有多种配置类型,如1核1G、2核2G、2核4G、8到16核32G等。这些配置可以满足大多数用户的需求,无论是电商站、视频还是游戏、小说等。...

useshellexecute为你推荐
轻量级服务器什么是轻量级应用服务器?阿里云服务器账号密码阿里云 云服务器liunx 用户名 和密码怎么设置可靠云主机买服务器合算还是用云主机靠谱?有什么好办法?在线修改图片背景怎样修改照片的背景国外手机号国外的手机号是什么样的??海外服务器免费ip地址谁知道怎么下载让自己的IP地址显示在国外,会的帮帮忙,谢谢服务器租用多少钱一月买一台能同时容纳100人在线的服务器需要多少钱?租呢?爱奇艺会员体验下载了千影浏览器怎么获得一周爱奇艺免费会员体验高带宽3兆最高网速能达到多少!~cdn能防ddos吗云主机可以防DDOS攻击吗?
南通服务器租用 花生壳免费域名 flashfxp怎么用 国内永久免费云服务器 免费个人空间申请 怎么测试下载速度 刀片服务器的优势 老左来了 赞助 国外免费asp空间 web服务器搭建 外贸空间 帽子云排名 德隆中文网 免费个人网页 闪讯网 SmartAXMT800 空间排行榜 linux服务器系统 alexa搜 更多