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中国新年特别套餐,洛杉矶1G内存VPS年付13.5美元起

CloudCone针对中国农历新年推出了几款特别套餐, 其中2019年前注册的用户可以以13.5美元/年的价格购买一款1G内存特价套餐,以及另外提供了两款不限制注册时间的用户可购买年付套餐。CloudCone是Quadcone旗下成立于2017年的子品牌,提供VPS及独立服务器租用,也是较早提供按小时计费VPS的商家之一,支持使用PayPal或者支付宝等付款方式。下面列出几款特别套餐配置信息。CP...

数脉科技:阿里云香港CN2线路服务器;E3-1230v2/16G/240G SSD/10Mbps/3IP,月付374元

数脉科技怎么样?昨天看到数脉科技发布了7月优惠,如果你想购买香港服务器,可以看看他家的产品,性价比还是非常高的。数脉科技对香港自营机房的香港服务器进行超低价促销,可选择10M、30M的优质bgp网络。目前商家有优质BGP、CN2、阿里云线路,国内用户用来做站非常不错,目前E3/16GB阿里云CN2线路的套餐有一个立减400元的优惠,有需要的朋友可以看看。点击进入:数脉科技商家官方网站香港特价阿里云...

hostkey俄罗斯、荷兰GPU显卡服务器/免费Windows Server

Hostkey.com成立于2007年的荷兰公司,主要运营服务器出租与托管,其次是VPS、域名、域名证书,各种软件授权等。hostkey当前运作荷兰阿姆斯特丹、俄罗斯莫斯科、美国纽约等数据中心。支持Paypal,信用卡,Webmoney,以及支付宝等付款方式。禁止VPN,代理,Tor,网络诈骗,儿童色情,Spam,网络扫描,俄罗斯色情,俄罗斯电影,俄罗斯MP3,俄罗斯Trackers,以及俄罗斯法...

useshellexecute为你推荐
华为服务器官方网站华为这个网页是真的吗?http://hw.haqcdh.com/changwan4c.html免费服务器资源免费资源赞助 免费赞助服务器 带宽 www.22w.comlinux开放8080端口linux系统,tomcat 8080端口,本机访问没问题,远程访问失败,dc4阀门执行器输出DC4-20mA反馈信号给控制室显示阀位,但控制室接收反馈信号的系统自带DC24V,导致阀位不准payoneer卡官网登录递四方后台怎么绑定payoneer卡国外免费域名申请谁给我个免费域名申请网站香港云服务器推荐香港服务器怎么样?哪个比较好啊?阿里云新用户老用户和新用户如何区分?域名解析记录值填什么域名解析分哪二种方式??jsp的虚拟主机java虚拟主机,jsp的语言用哪种空间呢
北京虚拟主机 备案域名 中文域名查询 美国php空间 好看的桌面背景图片 服务器怎么绑定域名 警告本网站 韩国名字大全 工信部icp备案号 网通服务器托管 创建邮箱 google台湾 免费外链相册 海外空间 新加坡空间 永久免费空间 卡巴斯基官网下载 512内存 腾讯云平台 海外加速 更多