怎么实现自动开关机的问题? 我想将我的电脑给个时间让它定时开关机该怎么写代码啊? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 使用Timer啊至于怎么关机,百度一下,关机的Win32 API 用系统时间与你规定的时间做比较`有时钟监视~~ 当他们相同的时候 调用shutdown命令就可以了 有段遠程關閉電腦的列子,可參考一下ConnectionOptions options = new ConnectionOptions(); options.Username = "diom\administrator";// textBox2.Text; options.Password = "123";//textBox3.Text; ManagementScope scope = new ManagementScope("\\\\" + IP + "\\root\\cimv2", options); try { string sss=System.Environment.UserName; //用给定管理者用户名和口令连接远程的计算机 scope.Connect(); ObjectQuery oq = new ObjectQuery("select * from win32_OperatingSystem"); ManagementObjectSearcher query1 = new ManagementObjectSearcher(scope, oq); ManagementObjectCollection queryCollection1 = query1.Get(); foreach (ManagementObject mo in queryCollection1) { string[] ss ={ "" }; string s1=mo["Caption"].ToString(); string s2 = mo["Manufacturer"].ToString(); string s3 = mo["csname"].ToString(); string s4 = mo["WindowsDirectory"].ToString(); string s5 = ""; mo.InvokeMethod("Reboot", ss); } } 哦 有创意马云说懒人创造了世界,在支撑这个世界前进看来楼主是马云的fans了 定时关机(直接就写上来了,好不好使还没试呢,不好使可别骂我, 你再调一下,应该这样是行的,呵呵):ProcessStartInfo info = new ProcessStartInfo(); info.FileName = "cmd.exe"; info.WindowStyle = ProcessWindowStyle.Hidden; info.Arguments = "shutdown -s -t 0"; info.WorkingDirectory = "C:\\";System.Timers.Timer bakTimer = new System.Timers.Timer(1000);bakTimer.Elapsed += new System.Timers.ElapsedEventHandler(bakTimer_Elapsed);private void bakTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e){ if(DataTime.Now == [你设定的关机时间]) //关机时间怎么设置,就不用我说了吧,看你喜欢的方式而定了 Process.Start(info);}定时开机我也不会? 等待高手,跟着学习一下 自动开机需要硬件支持,在BIOS里使用 电源管理功能自动关机.... 看LS各位叙述~如果你想实现自动开机使用代码,我想可以考虑察看一下关于系统休眠或者挂起的功能. 窗口创建句柄时错误 关于获取默认网关程序的错误 求教啊~ C# 日期计算 用户控件问题,输入值跟返回值??? C#新手,问问题! ---3 怎样在数据库中添加图形文件 各位大哥帮帮忙~ 怎样再Exe间传递参数? 一个关于DateTime的问题,紧急求助 如何将多个文件保存在一个文件中,如何从这个文件中读取 这有什么区别? 求一个测试函数运行时间的方法或函数!!!!
至于怎么关机,百度一下,关机的Win32 API
ConnectionOptions options = new ConnectionOptions();
options.Username = "diom\administrator";// textBox2.Text;
options.Password = "123";//textBox3.Text;
ManagementScope scope = new ManagementScope("\\\\" + IP + "\\root\\cimv2", options);
try
{
string sss=System.Environment.UserName;
//用给定管理者用户名和口令连接远程的计算机
scope.Connect();
ObjectQuery oq = new ObjectQuery("select * from win32_OperatingSystem");
ManagementObjectSearcher query1 = new ManagementObjectSearcher(scope, oq);
ManagementObjectCollection queryCollection1 = query1.Get();
foreach (ManagementObject mo in queryCollection1)
{
string[] ss ={ "" };
string s1=mo["Caption"].ToString();
string s2 = mo["Manufacturer"].ToString();
string s3 = mo["csname"].ToString();
string s4 = mo["WindowsDirectory"].ToString();
string s5 = "";
mo.InvokeMethod("Reboot", ss);
}
}
马云说懒人创造了世界,在支撑这个世界前进
看来楼主是马云的fans了
ProcessStartInfo info = new ProcessStartInfo();
info.FileName = "cmd.exe";
info.WindowStyle = ProcessWindowStyle.Hidden;
info.Arguments = "shutdown -s -t 0";
info.WorkingDirectory = "C:\\";System.Timers.Timer bakTimer = new System.Timers.Timer(1000);
bakTimer.Elapsed += new System.Timers.ElapsedEventHandler(bakTimer_Elapsed);private void bakTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
if(DataTime.Now == [你设定的关机时间]) //关机时间怎么设置,就不用我说了吧,看你喜欢的方式而定了
Process.Start(info);
}定时开机我也不会? 等待高手,跟着学习一下
自动关机.... 看LS各位叙述~如果你想实现自动开机使用代码,我想可以考虑察看一下关于系统休眠或者挂起的功能.