1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 using System.Diagnostics;
6
7 namespace c2
8 {
9 class Program
10 {
11 static void Main(string[] args)
12 {
13 if (runcmd("net localgroup administrators |find \"%username%\"").IndexOf(System.Environment.UserName) >= 0)
14 Console.WriteLine("Admin");
15 else
16 Console.WriteLine("No Admin!");
17 Console.Read();
18 }
19 private static string runcmd(string command)
20 {
21 Process p = new Process();
22 p.StartInfo.FileName = "cmd.exe";
23 p.StartInfo.Arguments = "/c " + command;
24 p.StartInfo.UseShellExecute = false;
25 p.StartInfo.RedirectStandardInput = true;
26 p.StartInfo.RedirectStandardOutput = true;
27 p.StartInfo.RedirectStandardError = true;
28 p.StartInfo.CreateNoWindow = true;
29 p.Start();
30 return p.StandardOutput.ReadToEnd();
31 }
32 }
33 }
34
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 using System.Diagnostics;
6
7 namespace c2
8 {
9 class Program
10 {
11 static void Main(string[] args)
12 {
13 if (runcmd("net localgroup administrators |find \"%username%\"").IndexOf(System.Environment.UserName) >= 0)
14 Console.WriteLine("Admin");
15 else
16 Console.WriteLine("No Admin!");
17 Console.Read();
18 }
19 private static string runcmd(string command)
20 {
21 Process p = new Process();
22 p.StartInfo.FileName = "cmd.exe";
23 p.StartInfo.Arguments = "/c " + command;
24 p.StartInfo.UseShellExecute = false;
25 p.StartInfo.RedirectStandardInput = true;
26 p.StartInfo.RedirectStandardOutput = true;
27 p.StartInfo.RedirectStandardError = true;
28 p.StartInfo.CreateNoWindow = true;
29 p.Start();
30 return p.StandardOutput.ReadToEnd();
31 }
32 }
33 }
34
net localgroup administrators |find \"%username%\"").IndexOf(System.Environment.UserName) >= 0
用这个命令也行