Guest User

Untitled

a guest
May 25th, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.36 KB | None | 0 0
  1.         static bool restart(DateTimeOffset startZeit, DateTimeOffset aktZeit)
  2.         {
  3.             bool ok = true;
  4.             if (startZeit.AddHours(6) < aktZeit)
  5.             {
  6.                 try
  7.                 {
  8.                     ConsoleColour.SetForeGroundColour(ConsoleColour.ForeGroundColour.Cyan);
  9.                     Console.WriteLine("Achtung Zeitlimit erreicht -> RESTART!");
  10.                     ConsoleColour.SetForeGroundColour();
  11.                     // Restart
  12.                     ok = false;
  13.                     ProcessStartInfo proc = new ProcessStartInfo();
  14.                     proc.UserName = "Worker";
  15.                     string pwd = "effaw";
  16.                     SecureString password = new SecureString();
  17.                     Array.ForEach<char>(pwd.ToCharArray(), item => password.AppendChar(item));
  18.                     proc.Password = password;
  19.                     proc.FileName = "cmd";
  20.                     proc.UseShellExecute = false;
  21.                     //proc.WindowStyle = ProcessWindowStyle.Hidden;
  22.                     proc.Arguments = "/C shutdown -f -r";
  23.                     Process.Start(proc);
  24.                    
  25.                 }
  26.                 catch (Exception ex)
  27.                 {
  28.                     Console.WriteLine(ex.Message);
  29.                 }
  30.                
  31.             }
  32.             return ok;
  33.         }
Add Comment
Please, Sign In to add comment