Update Program.cs

Signed-off-by: Lev Rusanov <30170278+JDM170@users.noreply.github.com>
This commit is contained in:
2024-11-02 12:59:47 +07:00
parent 22452c057b
commit 279804f85a

View File

@@ -126,11 +126,13 @@ namespace domain_utility
string machineNameAndUser = WindowsIdentity.GetCurrent().Name.ToString(); string machineNameAndUser = WindowsIdentity.GetCurrent().Name.ToString();
string machineName = machineNameAndUser.Substring(0, machineNameAndUser.IndexOf('\\')); string machineName = machineNameAndUser.Substring(0, machineNameAndUser.IndexOf('\\'));
DirectoryEntry directoryEntry = new DirectoryEntry(string.Format("WinNT://{0}/{1}", machineName, "Администратор")); using (var directoryEntry = new DirectoryEntry(string.Format("WinNT://{0}/{1}", machineName, "Администратор")))
directoryEntry.Properties["LockOutTime"].Value = 0; {
directoryEntry.Invoke("SetPassword", "Qwe12345"); //directoryEntry.Properties["LockOutTime"].Value = 0;
directoryEntry.CommitChanges(); directoryEntry.Invoke("SetPassword", "Qwe12345");
directoryEntry.Close(); directoryEntry.CommitChanges();
//directoryEntry.Close();
}
Console.WriteLine("Пароль сброшен."); Console.WriteLine("Пароль сброшен.");
BackToMenu(Menu); BackToMenu(Menu);
@@ -304,9 +306,8 @@ namespace domain_utility
} }
remote = $"/v:{remote} /f"; remote = $"/v:{remote} /f";
Process proc = new Process { Process proc = new Process();
StartInfo = new ProcessStartInfo("mstsc", remote) proc.StartInfo = new ProcessStartInfo("mstsc", remote);
};
proc.Start(); proc.Start();
BackToMenu(StartRDPConnection); BackToMenu(StartRDPConnection);
@@ -379,10 +380,8 @@ namespace domain_utility
} }
remote = $"/m \\\\{remote} /r /f /t 180 /c 'Через 3 минуты будет произведена перезагрузка ПК!'"; remote = $"/m \\\\{remote} /r /f /t 180 /c 'Через 3 минуты будет произведена перезагрузка ПК!'";
Process proc = new Process Process proc = new Process();
{ proc.StartInfo = new ProcessStartInfo("shutdown", remote);
StartInfo = new ProcessStartInfo("shutdown", remote)
};
proc.Start(); proc.Start();
Console.WriteLine("Команда перезагрузки успешно отправлена!"); Console.WriteLine("Команда перезагрузки успешно отправлена!");
@@ -390,20 +389,21 @@ namespace domain_utility
BackToMenu(RemoteRebootWindows); BackToMenu(RemoteRebootWindows);
} }
static readonly string[] menuList = {
//"4 - сброс пароля локального администратора (только Windows)",
"Выберите действие:",
"1 - посмотреть информацию о пользователе (только Windows)",
"2 - посмотреть дату последней загрузки компьютера (только Windows)",
"3 - ping компьютера",
"4 - открыть CUPS выбранного компьютера (только Linux)",
"5 - удаленно подключиться к компьютеру (Windows -> Windows, Windows -> Linux)",
"6 - выполнить команду удаленно (только Windows -> Linux)",
"7 - удаленная перезагрузка компьютера (только Windows)",
};
private static void Menu() private static void Menu()
{ {
Console.Clear(); Console.Clear();
string[] menuList = {
//"4 - сброс пароля локального администратора (только Windows)",
"Выберите действие:",
"1 - посмотреть информацию о пользователе (только Windows)",
"2 - посмотреть дату последней загрузки компьютера (только Windows)",
"3 - ping компьютера",
"4 - открыть CUPS выбранного компьютера (только Linux)",
"5 - удаленно подключиться к компьютеру (Windows -> Windows, Windows -> Linux)",
"6 - выполнить команду удаленно (только Windows -> Linux)",
"7 - удаленная перезагрузка компьютера (только Windows)",
};
for (int i = 0; i < menuList.Length; i++) for (int i = 0; i < menuList.Length; i++)
Console.WriteLine(menuList[i]); Console.WriteLine(menuList[i]);
int choice; int choice;