C#写的自动关机及执行CMD命令
using System;using System.Collections.Generic;bp@1HY|xZ
using System.ComponentModel;-XL#w7W@ {QF0\~
using System.Data; Uqm+H2lHF
using System.Drawing;6vn1e3Px6gJ
using System.Text;
using System.Windows.Forms;:k$wv9TTiq^
using System.Diagnostics;
namespace WindowsApplication17JlQ W }.ri
...{m1yM)fBe~b!rl
public partial class Form1 : Form
...{"N*MG7[i2lx4z/M
int i = 0;
private int ti;}c+i `M9vz:` i
public Form1()8G0H |tB/ENl ]
...{7j7u5GPx7`{
InitializeComponent();ZJ#v6N7N Tls_(x [
timer1.Enabled = false;
}~7zM,yx0i4n
public string CmdPc(string cmdinput)
...{D"q WpH*d'q4M0n
Process p = new Process();{9N)qT~Ud
p.StartInfo.FileName = "cmd.exe";8[*R;_1|B!q`8o8bG@
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardInput = true;.AR1g|1C
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.CreateNoWindow = true;
try
...{
p.Start();
p.StandardInput.WriteLine(cmdinput);Uhm{.pP?m
p.StandardInput.WriteLine("exit");(UXHLy r7[2_Y
string ss=p.StandardOutput.ReadToEnd();vfbe!eG7J
p.WaitForExit();
p.Close();
return ss;
}
catch
...{
string ss = "命令执行失败";
return ss;
}
}
5Y,igp-I
private void button1_Click(object sender, EventArgs e)
...{A.o6qYL
//label1.Text = ClosePc();ws-g4Jg
if (textBox2.Text != "")
...{