title: Checking for Reboot
body: <p>i am currently working on an Installation Support Program which does some important Tasks after a Setup. Now i've got the Problem, that i really need to identify, if a Reboot is required.</p>
  
  <p>My currently Code looks like that (forf the Check):</p>
  
  <pre><code>try
  {
      bool restart = false;
  
      Console.WriteLine("Prüfe auf Neustart...");
  
      SystemInformation t = new SystemInformation();
      if (t.RebootRequired){
          restart = true;
      }
  
      RegistryKey rk = null;
      rk = Registry.LocalMachine;
      rk = rk.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce");
  
      string[] r = rk.GetValueNames();
  
      if (r.Length != 0) { restart = true; }
  
      rk = Registry.CurrentUser;
      rk = rk.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce");
  
      r = rk.GetValueNames();
  
      if (r.Length != 0) { restart = true; }
  
      if (restart == true)
      {
          Console.WriteLine("Bitte starten Sie Ihren Rechner zuerst neu und führen das Setup dann nochmal aus...");
          Console.ReadKey();
          Environment.Exit(0);
      }
  }
  catch (Exception ex)
  {
      Console.WriteLine(ex.Message);
  }
  </code></pre>
  
  <p>Will this be enough or will i have to do more / other checks?</p>