Advertisement
Guest User

Untitled

a guest
Aug 12th, 2017
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.89 KB | None | 0 0
  1.  private void btn_flash_boot_Click(object sender, EventArgs e)
  2.         {
  3.             String source_path = txt_boot.Text;
  4.  
  5.  
  6.             if (File.Exists(source_path))
  7.             {
  8.  
  9.                 System.IO.File.Copy(source_path, "boot_AndroidControl.img", true);
  10.  
  11.                 //---Reboot in Bootloader
  12.                 StripStatus.Text = "rebooting bootloader...";
  13.  
  14.                 System.Diagnostics.ProcessStartInfo psi =
  15.                 new System.Diagnostics.ProcessStartInfo("C:/adb.exe", "reboot-bootloader");
  16.                 psi.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
  17.                 System.Diagnostics.Process.Start(psi).WaitForExit();
  18.  
  19.  
  20.                 // Checkt ob Gerät in Fastboot ist
  21.                 bool in_fastboot = false;
  22.                 while (in_fastboot == false)
  23.                 {
  24.  
  25.                     Process process = new Process();
  26.  
  27.                     process.StartInfo.UseShellExecute = false;
  28.                     process.StartInfo.RedirectStandardOutput = true;
  29.                     process.StartInfo.RedirectStandardError = true;
  30.                     process.StartInfo.CreateNoWindow = true;
  31.                     process.StartInfo.UseShellExecute = false;
  32.  
  33.  
  34.                     System.Threading.Thread.Sleep(500);
  35.  
  36.                     process.StartInfo.FileName = "C:/fastboot.exe ";
  37.                     process.StartInfo.Arguments = "devices";
  38.  
  39.                     process.Start();
  40.  
  41.                     string output = process.StandardOutput.ReadToEnd();
  42.  
  43.                     if (output.Contains("fastboot"))
  44.                     {
  45.                         in_fastboot = true;
  46.                     }
  47.                     else { in_fastboot = false; }
  48.  
  49.                 }
  50.  
  51.  
  52.                 StripStatus.Text = "flashing boot...";
  53.  
  54.                 System.Threading.Thread.Sleep(1500);
  55.  
  56.                 System.Diagnostics.ProcessStartInfo psi2 =
  57.                 new System.Diagnostics.ProcessStartInfo("C:/fastboot.exe", "flash boot boot_AndroidControl.img");
  58.                 psi2.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
  59.                 System.Diagnostics.Process.Start(psi2).WaitForExit();
  60.  
  61.                 System.Threading.Thread.Sleep(1500);
  62.  
  63.                 StripStatus.Text = "boot flashed, rebooting phone now...";
  64.                 System.Diagnostics.ProcessStartInfo psi4 =
  65.                 new System.Diagnostics.ProcessStartInfo("C:/fastboot.exe", "reboot");
  66.                 psi4.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
  67.                 System.Diagnostics.Process.Start(psi4).WaitForExit();
  68.  
  69.                 System.IO.File.Delete("boot_AndroidControl.img");
  70.                 System.Threading.Thread.Sleep(2500);
  71.                 StripStatus.Text = "Bereit";
  72.  
  73.  
  74.             }            
  75.  
  76.               else {
  77.                   MessageBox.Show("can't find recovery.img");
  78.               }
  79.  
  80.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement