Пример #1
0
        /*
        private void startwipeinstall()
        {
            Form1 f7 = new Form1();
            f7.WipeInstall1(filebeingdeployted);
            f7.Close();

        }
        private void WipeInstall(String x)
        {
            filebeingdeployted = x;
            new Thread(new ThreadStart(startwipeinstall)).Start();

        }
         * */
        private void WipeInstall(String x)
        {
            foreach (string file in windowsversionsd)
            {
                if (File.Exists(imagefilepath + "\\" + file))
                {
                    windowsimagefileexisits.Add(file);
                }
            }
            Boolean needtodownloadfile = true;
            if (downloadwim == true) //downloadwim == true //downloadwimfile //avaliblewimfordownload //windowsimagefileexisits
            {
                downloadwim = false;
                foreach (string l in windowsimagefileexisits)
                {
                    if (x.Trim() == l.Trim())
                    {
                        needtodownloadfile = false;
                    }
                } //TODO change this, make it look at an array (list) of files that need to be downloaded, then see if the current file is on that list, if so then open downloader.
                if (needtodownloadfile == true)
                {
                    downloadwim = true;
                    listdownloads f2 = new listdownloads();
                    f2.Show();
                    f2.downloadwimfile(x, deploymentfolderroot + "\\DeploymentImages\\", deployimgChkBx.Checked, false, deployafterdownload.Checked, deploymentfolderexists);
                    //f2.downloadwimfile(,,)
                    return;
                    //TODO Check if file really was downloaded.
                    //If it was, remove it from the list, rename button. If not, keep it in list of need to download, but add it to list of failed to download so it does't just keep looping.
                }
            }
            string strCmdText;
            if (WriteMBRChkBox.Checked == true && FormatDriveChkBx.Checked == true && createpartChkbx.Checked == true && DeletePartitionsChkBx.Checked == true)
            {
                try
                {
                    filterselecteddisk();
                    makediskpartscript();
                    strCmdText = "/c diskpart /s " + xDrive + "WipeC.txt";
                    System.Diagnostics.Process.Start("CMD.exe", strCmdText).WaitForExit();
                }
                catch (Exception crash)
                {
                    MessageBox.Show(crash.Message);
                }
            }
            if (deployimgChkBx.Checked == true)
            {
                try
                {
                    if (x != customwim)
                    {
                        strCmdText = String.Format("/c " + xDrive + "imagex.exe /apply {0}\\DeploymentImages\\" + x + " 1 " + mountdriveas, deploymentfolderroot);
                        System.Diagnostics.Process.Start("CMD.exe", strCmdText).WaitForExit();
                        if (WriteBCDChkBox.Checked == true)
                        {
                            strCmdText = "/c " + "bcdboot " + mountdriveas + "windows /s " + mountdriveas.Replace(@"\", "");
                            System.Diagnostics.Process.Start("CMD.exe", strCmdText).WaitForExit();
                        }
                    }
                    else
                    {
                        strCmdText = String.Format("/c " + xDrive + "imagex.exe /apply {0}" + x + " 1 " + mountdriveas, customwim);
                        System.Diagnostics.Process.Start("CMD.exe", strCmdText).WaitForExit();
                    }
                }
                catch (Exception crash)
                {
                    MessageBox.Show(crash.Message);
                }
            }
            else
            {
                MessageBox.Show("Deployment skipped: \n Deploy Image checkbox is unchecked");
            }
            if (autorebootChkBx.Checked == true)
            {
                strCmdText = "/c " + "shutdown /r /f /t 60";
                System.Diagnostics.Process.Start("CMD.exe", strCmdText).WaitForExit();
                this.Close();
            }
        }
Пример #2
0
        //TODO Ask user if he wants to make folder now
        public void scanforfolder()
        {
            string foundimagex = "no";
            //comboBox1.Items.Clear();
            comboBox3.Items.Clear();
            Boolean downloadbcdboot = false;
            Boolean downloadimagex2 = false;
            var key = Registry.LocalMachine.OpenSubKey(@"Software\Microsoft\Windows NT\CurrentVersion\WinPE");
            if (key != null) //Checks if we are running in WinPE. if so then the next line of code is exicuted.
            {
                xDrive = Path.GetPathRoot(Environment.SystemDirectory); // C:\
            }
            Boolean isExists = false;

            foreach (var drive in DriveInfo.GetDrives())
            {
                if (drive.IsReady == true)
                {
                    comboBox3.Items.Add(drive.Name + " " + drive.TotalSize / 1073741824 + " GB");
                    usedDriveLetters.Add(drive.Name);
                    string q = drive.Name + "DeploymentImages";
                    if (Directory.Exists(@q))
                    {
                        imagefilepath = q; //Should be ?:\DeploymentImages
                        deploymentfolderexists = true;
                        deploymentfolderroot = drive.Name; // Should show up as x:\
                    }
                    if (File.Exists(drive.Name + "imagex.exe"))
                    {
                        xDrive = drive.Name;
                        foundimagex = "yes";
                    }
                    if (File.Exists(drive.Name + "bcdboot.exe"))
                    {
                        bcdbootlocation = drive.Name;
                    }

                }
            }

            if (xDrive == "notfound" && imagefilepath == "notfound")
            {
                //MessageBox.Show("File not found: imagex.exe \nFolder not found: DeploymentImages \nPlease choose a drive, and create a folder named DeploymentImages\nPlease choose a drive, and place imagex.exe on the root\nDeployment will not be possible", "AutoDeploy");
                if (!isExists)
                {
                    System.IO.Directory.CreateDirectory(Application.StartupPath + "\\DeploymentImages");
                    imagefilepath = Application.StartupPath + "\\DeploymentImages\\";
                    //xDrive = Application.StartupPath + "\\DeploymentImages";
                    deploymentfolderexists = true;
                }
                if (isExists)
                {
                    imagefilepath = Application.StartupPath + "\\DeploymentImages\\";
                    //xDrive = Application.StartupPath + "\\DeploymentImages";
                    deploymentfolderexists = true;
                }
            }
            if (xDrive == "notfound")
            {
                isExists = System.IO.Directory.Exists(Application.StartupPath + "\\DeploymentImages");
                if (isExists)
                {
                    xDrive = Application.StartupPath + "\\DeploymentImages\\";
                    deploymentfolderroot = Application.StartupPath;
                }
            }
            if (xDrive != "notfound" && imagefilepath == "notfound")
            {
                MessageBox.Show("Warning: Unable to detect deployment image folder. \nDeployment will not be possible without that folder\nPlease create the folder \"DeploymentImages\" on the root of any drive", "AutoDeploy");
                deploymentfolderexists = false;

            }
            if (bcdbootlocation == "notfound" && imagefilepath != "notfound")
            {
                if (!File.Exists(imagefilepath + "bcdboot.exe"))
                {
                    DialogResult result2 = MessageBox.Show("bcdboot.exe not found. Deployment will not be possible. \nWould you like to download it to " + imagefilepath + " ?",
                        "AutoDeploy",
                        MessageBoxButtons.YesNoCancel,
                        MessageBoxIcon.Question);
                    if (result2 == DialogResult.Yes)
                    {
                        downloadbcdboot = true;
                    }
                    if (result2 == DialogResult.No)
                    {

                    }
                    if (result2 == DialogResult.Cancel)
                    {
                        Environment.Exit(0);
                    }
                }
            }
            System.Threading.Thread.Sleep(500);
            if (!File.Exists(imagefilepath + "imagex.exe") && !File.Exists(deploymentfolderroot + "imagex.exe") && foundimagex == "no")
            {
                //MessageBox.Show(Application.StartupPath);
                DialogResult result2 = MessageBox.Show("imagex.exe not found. Deployment will not be possible. \nWould you like to download it to " + imagefilepath + " ?",
                    "AutoDeploy",
                MessageBoxButtons.YesNoCancel,
                MessageBoxIcon.Question);
                if (result2 == DialogResult.Yes)
                {
                    downloadimagex2 = true;
                }
                if (result2 == DialogResult.No)
                {

                }
                if (result2 == DialogResult.Cancel)
                {
                    Environment.Exit(0);
                }
            }
            if (downloadbcdboot == true)
            {   //downloadwim("imagex.exe");
                listdownloads f2 = new listdownloads();
                f2.Show();
                f2.downloadwimfile("bcdboot.exe", imagefilepath, false, true, deployafterdownload.Checked, deploymentfolderexists);

            }
            if (downloadimagex2 == true)
            {
                //downloadwim("imagex.exe");
                listdownloads f2 = new listdownloads();
                f2.Show();
                f2.downloadwimfile("imagex.exe", imagefilepath, false, true, deployafterdownload.Checked, deploymentfolderexists);
            }
            /*
            string u = "";
            foreach (var drive in DriveInfo.GetDrives())
            {

                if (drive.IsReady == true)
                {
                    comboBox3.Items.Add(drive.Name + " " + drive.TotalSize / 1073741824 + " GB");
                    usedDriveLetters.Add(drive.Name);
                    string q = drive.Name + "DeploymentImages";
                    if (Directory.Exists(@q))
                    {
                        imagefilepath = q; //Should be ?:\DeploymentImages
                        u = drive.Name; // Should show up as x:\
                    }
                    if (File.Exists(drive.Name + "imagex.exe"))
                    {
                        xDrive = drive.Name;
                    }
                }
            }
            var key = Registry.LocalMachine.OpenSubKey(@"Software\Microsoft\Windows NT\CurrentVersion\WinPE");
            if (key != null)
            {
                xDrive = Path.GetPathRoot(Environment.SystemDirectory); // C:\
            }
            else
            {
                xDrive = u;
                if (!imagefilepath.Contains("notfound"))
                {
                    MessageBox.Show("Looks like you are running this program outside of WinPE \n Images will be saved in " + imagefilepath);
                }
            }
            if (imagefilepath.Contains("notfound"))
            {

                MessageBox.Show("Warning: Unable to detect deployment image folder. \n It should be called \"DeploymentImages\" on the root of any drive \n Example: D:\\DeploymentImages\\",
                "Auto Deploy",
                MessageBoxButtons.OK,
                MessageBoxIcon.Exclamation,
                MessageBoxDefaultButton.Button1);
            }
             * */
        }
Пример #3
0
 private void downloadISOToolStripMenuItem_Click(object sender, EventArgs e)
 {
     listdownloads f2 = new listdownloads();
     f2.Show();
     f2.downloadwimfile("winpe_x64.iso", deploymentfolderroot, false, true, deployafterdownload.Checked, deploymentfolderexists);
 }