예제 #1
0
파일: Scan.cs 프로젝트: powerdudeg4/Redows
        private void btnStart_Click(object sender, EventArgs e)
        {
            try
            {
                try
                {
                    if (VERIFICATION_ACTIFOUPAS == true)
                    {
                        //Cursor.Current = Cursors.AppStarting;
                        WebClient MAJ          = new WebClient();
                        string    ACTIF_OU_PAS = MAJ.DownloadString("https://brunopaiva.ch/Actif.txt");

                        if (ACTIF_OU_PAS != "1")
                        {
                            //Cursor.Current = Cursors.Default;
                            MessageBox.Show("Redows is not available at the moment.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);

                            Quit quit = new Quit();

                            this.Hide();

                            quit.ShowDialog();
                        }
                    }
                }
                catch
                {
                    if (VERIFICATION_ACTIFOUPAS == true)
                    {
                        VERIFICATION_ACTIFOUPAS = true;
                    }
                    else
                    {
                        MessageBox.Show("Redows was unable to contact the central server. We strongly recommend that you do not carry out any repairs.", "Network error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        //Cursor.Current = Cursors.Default;
                        VERIFICATION_ACTIFOUPAS = false;
                    }
                }

                //Wait wait = new Wait();

                //wait.Show();

                lblTitre.Visible        = false;
                lblEnReparation.Visible = true;

                lblEnReparation.ForeColor = Color.White;
                this.BackColor            = Color.Red;

                btnModeExpert.Enabled = false;
                btnStart.Enabled      = false;

                Cursor.Current = Cursors.WaitCursor;

                btnStart.Text = "Repair in progress (Step 1/3)...";

                Process procSFC = new Process();
                procSFC.StartInfo.FileName = "cmd.exe";
                if (bCacherFenetre == true)
                {
                    procSFC.StartInfo.Arguments = "/k Dism /Online /Cleanup-Image /ScanHealth & exit";
                }
                else
                {
                    procSFC.StartInfo.Arguments = "/k Dism /Online /Cleanup-Image /ScanHealth";
                }
                procSFC.StartInfo.ErrorDialog = true;
                procSFC.StartInfo.Verb        = "runas";
                if (bCacherFenetre == true)
                {
                    procSFC.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
                }
                else
                {
                    procSFC.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
                }
                procSFC.Start();
                procSFC.WaitForExit();

                //Cursor.Current = Cursors.Default;
                //Cursor.Current = Cursors.AppStarting;

                Process proc = new Process();
                proc.StartInfo.FileName = "cmd.exe";
                if (bCacherFenetre == true)
                {
                    proc.StartInfo.Arguments = "/k Dism /Online /Cleanup-Image /CheckHealth & exit";
                }
                else
                {
                    proc.StartInfo.Arguments = "/k Dism /Online /Cleanup-Image /CheckHealth";
                }
                proc.StartInfo.ErrorDialog = true;
                proc.StartInfo.Verb        = "runas";
                if (bCacherFenetre == true)
                {
                    proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
                }
                else
                {
                    proc.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
                }
                proc.Start();
                //Cursor.Current = Cursors.WaitCursor;
                proc.WaitForExit();

                btnStart.Text = "Repair in progress (Step 2/3)....";

                //Cursor.Current = Cursors.Default;
                //Cursor.Current = Cursors.AppStarting;

                Process proc1 = new Process();
                proc1.StartInfo.FileName = "cmd.exe";
                if (bCacherFenetre == true)
                {
                    proc1.StartInfo.Arguments = "/k Dism /Online /Cleanup-Image /RestoreHealth & exit";
                }
                else
                {
                    proc1.StartInfo.Arguments = "/k Dism /Online /Cleanup-Image /RestoreHealth";
                }
                proc1.StartInfo.ErrorDialog = true;
                proc1.StartInfo.Verb        = "runas";
                if (bCacherFenetre == true)
                {
                    proc1.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
                }
                else
                {
                    proc1.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
                }
                proc1.Start();
                //Cursor.Current = Cursors.WaitCursor;
                proc1.WaitForExit();

                btnStart.Text = "Repair in progress (Step 3/3)...";

                //Cursor.Current = Cursors.Default;
                //Cursor.Current = Cursors.AppStarting;

                Process proc2 = new Process();
                proc2.StartInfo.FileName = "cmd.exe";
                if (bCacherFenetre == true)
                {
                    proc2.StartInfo.Arguments = "/k chkdsk c: /scan /forceofflinefix & exit";
                }
                else
                {
                    proc2.StartInfo.Arguments = "/k chkdsk c: /scan /forceofflinefix";
                }
                proc2.StartInfo.ErrorDialog = true;
                proc2.StartInfo.Verb        = "runas";
                if (bCacherFenetre == true)
                {
                    proc2.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
                }
                else
                {
                    proc2.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
                }
                proc2.Start();
                //Cursor.Current = Cursors.WaitCursor;
                proc2.WaitForExit();

                btnStart.Text = "Repair completed";

                Cursor.Current = Cursors.Default;

                this.BackColor          = Color.White;
                lblTitre.Visible        = true;
                lblEnReparation.Visible = false;

                //wait.Close();

                MessageBox.Show("Repair successfully completed.", "Success", MessageBoxButtons.OK);

                End end = new End();

                this.Hide();

                end.ShowDialog();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Oh. An unknown error occurred.\n\nError : " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }