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

BuyVM迈阿密KVM上线,AMD Ryzen 3900X+NVMe硬盘$2/月起

BuyVM在昨天宣布上线了第四个数据中心产品:迈阿密,基于KVM架构的VPS主机,采用AMD Ryzen 3900X CPU,DDR4内存,NVMe硬盘,1Gbps带宽,不限制流量方式,最低$2/月起,支持Linux或者Windows操作系统。这是一家成立于2010年的国外主机商,提供基于KVM架构的VPS产品,数据中心除了新上的迈阿密外还包括美国拉斯维加斯、新泽西和卢森堡等,主机均为1Gbps带...

hostyun评测香港原生IPVPS

hostyun新上了香港cloudie机房的香港原生IP的VPS,写的是默认接入200Mbps带宽(共享),基于KVM虚拟,纯SSD RAID10,三网直连,混合超售的CN2网络,商家对VPS的I/O有大致100MB/S的限制。由于是原生香港IP,所以这个VPS还是有一定的看头的,这里给大家弄个测评,数据仅供参考!9折优惠码:hostyun,循环优惠内存CPUSSD流量带宽价格购买1G1核10G3...

六一云互联(41元)美国(24元)/香港/湖北/免费CDN/免费VPS

六一云互联六一云互联为西安六一网络科技有限公司的旗下产品。是一个正规持有IDC/ISP/CDN的国内公司,成立于2018年,主要销售海外高防高速大带宽云服务器/CDN,并以高质量.稳定性.售后相应快.支持退款等特点受很多用户的支持!近期公司也推出了很多给力的抽奖和折扣活动如:新用户免费抽奖,最大可获得500元,湖北新购六折续费八折折上折,全场八折等等最新活动:1.湖北100G高防:新购六折续费八折...

useshellexecute为你推荐
华为云终端华为手机负一屏怎么设置?华为云服务找回手机我华为的手机遗失了,但是没有开启查找手机位置的功能,我该如何找回?xshell教程请问安卓有什么软件具有xshell的功能加速云安卓5.0手机中辅助功能里的加速引擎是什么意思?好看的表格样式创意怎么设计漂亮的excel 表格域名分类域名的基本类型有哪些?bgp服务器租用服务器线路里的BGP和多线服务器租用是一样的吗?网站预防ddos攻击怎样才能避免PC免受DDOS攻击?四叶草安全四叶草汽车用品儿童汽车安全座椅怎么样,质量好不好吗?io域名注册id域名怎么注册?
独立ip虚拟主机 个人域名备案流程 大硬盘 狗爹 美元争夺战 la域名 炎黄盛世 howfile 上海电信测速网站 架设邮件服务器 工信部icp备案查询 万网注册 阿里云邮箱个人版 rewritecond 开心online 香港博客 沈阳idc 美国主机 标准机柜 西部数码主机 更多