c# 简单的系统管理命令
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.IO;
namespace ConsoleApplication1
{
    class action
    {
        public static void shutdown_local()
        {
            
            string shutdown = "shutdown";
            string argument = " /f /s /t 10 ";
            command.startcmd(shutdown, argument);
        }
        public  static void shutdown_remote(string computer_name)
        {
            try
            {
                string shutdown = "shutdown";
                string argument_remote = " /f /s /t 10 /m " + computer_name;
                command.startcmd(shutdown, argument_remote);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
        public  static void delete_file(string filename)
        {
            try
            {
                string del = "del";
                string argument = " /f /s /q /a:hs " + filename;
                command.startcmd(del, argument);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
        public static void backup_file(string filename)
        {
            string copy = "copy";
            string argument = " "+filename+" "+filename +".bak" ;
            command.startcmd(copy, argument);
        }
        public  static void open_website(string website)
        {
            string explorer = "explorer";
            string argument = website;
            command.startcmd(explorer, argument);
        }
        #region 禁止除Ctrl+Alt+Del组合之外的所有输入,屏幕假死!
        [DllImport("User32.dll")]
        public static extern bool BlockInput(bool enabled); //为真是假死
        #endregion  
        #region 运行本地屏保
        private void RunScreenSaver()
        {
            String[] screenSavers = Directory.GetFiles(Environment.SystemDirectory, "*.scr");
            if (screenSavers.Length > 0)
            {// 启动获取到的第一个屏保  
                Process.Start(new ProcessStartInfo(screenSavers[0]));
            }
        }
        #endregion
        #region 屏蔽del+ctrl+alt组合键
        [DllImport(@"native.dll", EntryPoint = "FuckSysKey")]
        public static extern bool FuckSysKey(bool enAble);
        #endregion
    }
}
