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

CloudCone中国春节优惠活动限定指定注册时间年付VPS主机$13.5

CloudCone 商家产品还是比较有特点的,支持随时的删除机器按时间计费模式,类似什么熟悉的Vultr、Linode、DO等服务商,但是也有不足之处就在于机房太少。商家的活动也是经常有的,比如这次中国春节期间商家也是有提供活动,比如有限定指定时间段之前注册的用户可以享受年付优惠VPS主机,比如年付13.5美元。1、CloudCone新年礼物限定款仅限2019年注册优惠购买,活动开始时间:1月31...

friendhosting:(优惠55%)大促销,全场VPS降价55%,9个机房,不限流量

每年的7月的最后一个周五是全球性质的“系统管理员日”,据说是为了感谢系统管理员的辛苦工作....friendhosting决定从现在开始一直到9月8日对其全球9个数据中心的VPS进行4.5折(优惠55%)大促销。所有VPS基于KVM虚拟,给100M带宽,不限制流量,允许自定义上传ISO...官方网站:https://friendhosting.net比特币、信用卡、PayPal、支付宝、微信、we...

触碰云高性价20.8元/月,香港云服务器,美国cn2/香港cn2线路,4核4G15M仅115.2元/月起

触碰云怎么样?触碰云是一家成立于2019年的商家。触碰云主营香港/美国 VPS服务器、独立服务器以及免备案CDN。采用的是kvm虚拟构架,硬盘Raid10,Cn2线路,去程电信CN2、移动联通直连,回程三网CN2。最低1核1G带宽1M仅20.8元/月,不过这里推荐香港4核4G15M,香港cn2 gia线路云服务器,仅115.2元/月起,性价比还是不错的。点击进入:触碰云官方网站地址触碰云优惠码:优...

useshellexecute为你推荐
安装wget命令LINUX下wget的使用cdn加速教程CDN如何实现互联网动态加速?亚马逊服务器价格亚马逊云计算的价格蛮高的,国内性价比好点的有什么云计算?短信验证码英文qq邮箱开启pop3和imap服务需要的16位英文验证码需要往哪个平台发短信获取阿里云如何重装系统怎么重新安装系统?快云服务器快云服务器性价比怎么样??gd域名注册急求GD域名抢注教程vc9运行库下载求VC2005 VC2008运行库下载,最好是官方中文版,谢谢!免费永久个人网站注册怎么免费创建自己的网站?域名分类域名如何分类?
淘宝虚拟主机 已备案域名 服务器租用托管 香港vps主机 site5 la域名 网络星期一 ubuntu更新源 tightvnc php免费空间 双拼域名 已备案删除域名 可外链网盘 可外链相册 广州服务器 100mbps 台湾谷歌 银盘服务是什么 空间登录首页 登陆空间 更多