如题!需求:设置电脑每天晚上0点自动关机,8点自动开机!有没有用c#编写的源码!

解决方案 »

  1.   

    关机的代码LZ可以百度一下,有很多的。
    开机的话需要主板支持才行吧,C#好像做不到诶。
      

  2.   

    c# 内嵌at command cmd
    -shutdown at time
    就OK了
      

  3.   

    定时关机的话还做过,定时开机没弄过。
    定时关机可以用win32 API,楼主去搜下,应该很多的。
      

  4.   

    定时关机       
              Process 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();
               p.StandardInput.WriteLine("at time shutdown -s");   //填CMD命令
               p.StandardInput.WriteLine("exit ");
               string strRst = p.StandardOutput.ReadToEnd();
               MessageBox.Show(strRst);
               p.WaitForExit();定时开机需要BIOS支持, 提供接口
      

  5.   

    定时开机需要主板支持。
    定时关机就比较简单,windows自带的计划任务就能完成。
    最多写个bat文件,命令一句搞定。shutdown -s
      

  6.   

    定时关机没问题
    12点的时候调用
    ProcessStartInfo psi = new ProcessStartInfo("shutdown", "/s /t 300 /c 关机了");
    Process.Start(psi);定时开机就...
      

  7.   

    如果楼主的意思主要只是为了省电,并且希望早上上班的时候没有那么长的开机过程的话,可以设置电脑不使用一小时后“待机”,早上按下break就自动起来了。很快的
      

  8.   

    如果楼主的意思主要只是为了省电,并且希望早上上班的时候没有那么长的开机过程的话,可以设置电脑不使用一小时后“待机”,早上按下break就自动起来了。很快的
      

  9.   

    shutdown.exe-s-t 3600 命令就可以,如果不行,参考一下情况。
    1 在运行中键入”services.msc”,查看”Task Scheduler”服务是否被设置成了”已禁用”,若是,要双击它将启动类型改为”自动”;2 运行”gpedit.msc”来编辑组策略:展开”计算机配置→Windows设置→安全设置→本地计算机策略→安全选项”,找到"域控制器:允许服务器操作员计划任务"并启用它打开控制面板--任务计划--添加任务计划--
    1.打开向导,下一步>在应用程序框中找到C盘里的shutdown.exe程序,然后在shutdown.exe的后面输入“  /s”,不包括引号,下一步>选中"每天"执行任务,下一步输入定时关机时间,日期不变,下一步用户名中使用当前系统默认的不必输入,再输入用户密码,点击"显示任务属性..",再单击完成.2.在向导中创建完成一个"任务计划"后,再在此任务上右键点"属性">"任务"标签中勾选"仅在登录后运行">"确定","任务计划"就能正常运行了
      

  10.   

    远程开机是windows推nt平台时的广告。但需要主板支持。
    后来。windows也承认这个是败笔。几乎没有人用。
      

  11.   

    1、定时关机,这个代码有
    using System.Runtime.InteropServices;  // 提供DllImport等特性,是P/Invoke的关键
       // 这个结构体将会传递给API。使用StructLayout(...特性,确保其中的成员是按顺序排列的,C#编译器不会对其进行调整。          [StructLayout(LayoutKind.Sequential, Pack = 1)]
              internal struct TokPriv1Luid
              {
                  public int Count;
                  public long Luid;
                  public int Attr;
              }
              // 以下使用DllImport特性导入了所需的Windows API。          // 导入的方法必须是static extern的,并且没有方法体。调用这些方法就相当于调用Windows API。          [DllImport("kernel32.dll", ExactSpelling = true)]
              internal static extern IntPtr GetCurrentProcess();          [DllImport("advapi32.dll", ExactSpelling = true, SetLastError = true)]
              internal static extern bool OpenProcessToken(IntPtr h, int acc, ref IntPtr phtok);          [DllImport("advapi32.dll", SetLastError = true)]
              internal static extern bool LookupPrivilegeValue(string host, string name, ref long pluid);          [DllImport("advapi32.dll", ExactSpelling = true, SetLastError = true)]
              internal static extern bool AdjustTokenPrivileges(IntPtr htok, bool disall,
              ref TokPriv1Luid newst, int len, IntPtr prev, IntPtr relen);          [DllImport("user32.dll", ExactSpelling = true, SetLastError = true)]
              internal static extern bool ExitWindowsEx(int flg, int rea);
              // 以下定义了在调用WinAPI时需要的常数。这些常数通常可以从Platform SDK的包含文件(头文件)中找到          internal const int SE_PRIVILEGE_ENABLED = 0x00000002;
              internal const int TOKEN_QUERY = 0x00000008;
              internal const int TOKEN_ADJUST_PRIVILEGES = 0x00000020;
              internal const string SE_SHUTDOWN_NAME = "SeShutdownPrivilege";
              internal const int EWX_LOGOFF = 0x00000000;
              internal const int EWX_SHUTDOWN = 0x00000001;
              internal const int EWX_REBOOT = 0x00000002;
              internal const int EWX_FORCE = 0x00000004;
              internal const int EWX_POWEROFF = 0x00000008;
              internal const int EWX_FORCEIFHUNG = 0x00000010;
              // 通过调用WinAPI实现关机,主要代码再最后一行ExitWindowsEx,这调用了同名的WinAPI,正好是关机用的。          private static void DoExitWin(int flg)
              {
                  bool ok;
                  TokPriv1Luid tp;
                  IntPtr hproc = GetCurrentProcess();
                  IntPtr htok = IntPtr.Zero;
                  ok = OpenProcessToken(hproc, TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, ref htok);
                  tp.Count = 1;
                  tp.Luid = 0;
                  tp.Attr = SE_PRIVILEGE_ENABLED;
                  ok = LookupPrivilegeValue(null, SE_SHUTDOWN_NAME, ref tp.Luid);
                  ok = AdjustTokenPrivileges(htok, false, ref tp, 0, IntPtr.Zero, IntPtr.Zero);
                  ok = ExitWindowsEx(flg, 0);
              } 
           private void button1_Click(object sender, EventArgs e)
            {
                DoExitWin(EWX_SHUTDOWN);
            }2、定时开机,要在BIOS时设置电源管理哪设置就行了
    触摸屏我们长期这样搞,现在主板都有这功能。
      

  12.   

    用休眠替换关机,可以设定一个时钟 到时间自动起来的 不用去BIOS里面设置 效果跟关机差不多啦。、
      

  13.   

    本来想法是,通过软件能够设置好BIOS,这样实现定时开机,其实直接改BIOS是可以的。还有个思路是定时休眠,然后启动,这个应该可以实现吧。
      

  14.   

    软件直接肯定不可以,windows有自带的sechedule可以做到。
    使用kernel32.dll也可以做到定时开机(不知道具体怎么做)他们都是通过设置rtc来实现的