protected override int OnExecute(CommandLineApplication app) { if (!Utils.HasAdmin()) Console.WriteLine("Please run this command as Administrator or it might fail!"); try { TerminalService.RestartServices(); } catch (Exception ex) { Console.WriteLine($"Failed to restart services: {ex.Message}"); } return 0; }
protected override int OnExecute(CommandLineApplication app) { if (!Utils.HasAdmin()) Console.WriteLine("Please run this command as Administrator or it might fail!"); try { RegistrySecurity oldrs = null; oldrs = TerminalService.SetGracePeriodRegistryKeyPermission(); TerminalService.ResetGracePeriodVal(); Console.WriteLine($"Grace period is reset"); if (oldrs != null) TerminalService.SetGracePeriodRegistryKeyPermission(oldrs); if (RestartServices) TerminalService.RestartServices(); } catch (Exception ex) { Console.WriteLine(ex.Message); return -1; } return 0; }
protected override int OnExecute(CommandLineApplication app) { Console.WriteLine(Utils.ByteArrayToString(TerminalService.GetGracePeriodValRaw())); return 0; }