我似乎无法让它发挥作用,唯一发生的事情是CMD提示弹出如何使用网络功能,如果你可以帮助我,我将不胜感激。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.IO;
namespace Enable_Elevated_Admin
{
class Program
{
static void Main(string[] args)
{
Console.Title = "Enable Admin";
Process enable_admin = new Process();
Process disable_admin = new Process();
enable_admin.StartInfo.Arguments = "user " + "administrator" + "/active:yes";
enable_admin.StartInfo.FileName = @"C:\Windows\System32\net";
disable_admin.StartInfo.Arguments = "user " + "administrator" + "/active:no";
disable_admin.StartInfo.FileName = @"C:\Windows\System32\net";
ConsoleKeyInfo i;
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("Welcome to ClassyJakey's C# project for enabling the elevated admin easily.");
Console.WriteLine("Options :");
Console.WriteLine("1) Enable elevated admin");
Console.WriteLine("2) Disable elevated admin");
i = Console.ReadKey();
if (i.KeyChar.ToString() == "1")
{
Console.WriteLine("Enabling admin, please wait!");
enable_admin.Start();
Console.WriteLine("Enabled!");
Console.ReadKey();
Console.WriteLine("Creating log...");
StreamWriter writer = new StreamWriter("c:\\log.txt");
writer.WriteLine(System.DateTime.Today);
writer.WriteLine("Enable Admin Log - By ClassyJakey");
writer.WriteLine("Enabling admin was successful!");
writer.WriteLine("If you have errors, please contact classyjakey.");
writer.Close();
}
if (i.KeyChar.ToString() == "2")
{
Console.WriteLine("Disabling admin, please wait!");
disable_admin.Start();
Console.WriteLine("Disabled!");
Console.ReadKey();
StreamWriter writer2 = new StreamWriter("c:\\log2.txt");
writer2.WriteLine(System.DateTime.Today);
writer2.WriteLine("Enable Admin Log - By ClassyJakey");
writer2.WriteLine("Disabling! admin was successful!");
writer2.WriteLine("If you have errors, please contact classyjakey.");
writer2.Close();
}
else
{
Console.WriteLine("You thought you would find a easter egg by not putting 1 or 2?");
Console.WriteLine("Well, your right.");
Console.WriteLine("+ o + o ");
Console.WriteLine(" + o + +");
Console.WriteLine("o + ");
Console.WriteLine(" o + + + ");
Console.WriteLine("+ o o + o");
Console.WriteLine("-_-_-_-_-_-_-_,------, o ");
Console.WriteLine(@"_-_-_-_-_-_-_-| /\_/\ meow ");
Console.WriteLine("-_-_-_-_-_-_-_|__( ^ w^) + +");
Console.WriteLine(@"_-_-_-_-_-_-_- "" "" ");
Console.WriteLine("+ o o + o ");
Console.WriteLine(" + + ");
Console.WriteLine("o o o o +");
Console.WriteLine(" o + ");
Console.WriteLine("+ + o o + ");
StreamWriter writer3 = new StreamWriter("c:\\log3.txt");
writer3.WriteLine(System.DateTime.Today);
writer3.WriteLine("+ o + o ");
writer3.WriteLine(" + o + +");
writer3.WriteLine("o + ");
writer3.WriteLine(" o + + + ");
writer3.WriteLine("+ o o + o");
writer3.WriteLine("-_-_-_-_-_-_-_,------, o ");
writer3.WriteLine(@"_-_-_-_-_-_-_-| /\_/\ meow ");
writer3.WriteLine("-_-_-_-_-_-_-_|__( ^ w^) + +");
writer3.WriteLine(@"_-_-_-_-_-_-_- "" "" ");
writer3.WriteLine("+ o o + o ");
writer3.WriteLine(" + + ");
writer3.WriteLine("o o o o +");
writer3.WriteLine(" o + ");
writer3.WriteLine("+ + o o + ");
writer3.Close();
Console.ReadKey();
}
}
}
}
答案 0 :(得分:0)
可能是因为您错过了一个空格来分隔参数:
enable_admin.StartInfo.Arguments = "user " + "administrator " + "/active:yes";
^----
enable_admin.StartInfo.FileName = @"C:\Windows\System32\net";
disable_admin.StartInfo.Arguments = "user " + "administrator " + "/active:no";
^----
disable_admin.StartInfo.FileName = @"C:\Windows\System32\net";