private void btnInstall_Click(object sender, EventArgs e) { // Add firefox if (txtFirefoxVer.Text == "Latest") { levCheckbox4Software.Add(new LevCheckbox(chkFirefox, "https://download.mozilla.org/?product=firefox-latest&os=win&lang=en-US", "FirefoxLatest.exe", "FirefoxLatest.exe /S")); } else { levCheckbox4Software.Add(new LevCheckbox(chkFirefox, "https://ftp.mozilla.org/pub/firefox/releases/" + txtFirefoxVer.Text + ".0/win32/en-US/Firefox%20Setup%20" + txtFirefoxVer.Text + ".0.exe", "FirefoxSetup.exe", "FirefoxSetup.exe /S")); } StatusForm statusForm = new StatusForm(levCheckbox4Software); statusForm.Show(); WebClient wc = new WebClient(); Task t = new Task(() => { foreach (LevCheckbox levCheckbox in levCheckbox4Software) { if (levCheckbox.checkBox.Checked) { ServicePointManager.Expect100Continue = true; ServicePointManager.DefaultConnectionLimit = 9999; // Limitation: .NET 3.5 doesn't support TLS 1.2 // ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls; // For .NET 3.5 and .NET 4 ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls | SecurityProtocolType.Tls12; //For .NET 4.5 ServicePointManager.ServerCertificateValidationCallback = delegate { return(true); }; levCheckbox.updateDownloadingStatus(); statusForm.updateProgress(); try { wc.DownloadFile(levCheckbox.softwareURL, Path.GetTempPath() + levCheckbox.setupFileName); } catch (Exception ex) { levCheckbox.remark = ex.Message; } finally { levCheckbox.updateInstallingStatus(); } statusForm.updateProgress(); levCheckbox.updateResultStatus(executeCommand(Path.GetTempPath() + levCheckbox.command, true)); statusForm.updateProgress(); } } wc.Dispose(); }); t.Start(); }
private void btnConfigWindows_Click(object sender, EventArgs e) { StatusForm statusForm = new StatusForm(levCheckbox4WindowsList); statusForm.Show(); Thread t = new Thread(() => { foreach (LevCheckbox levCheckbox in levCheckbox4WindowsList) { if (levCheckbox.checkBox.Checked) { levCheckbox.updateResultStatus(executeCommand(levCheckbox.command, true)); statusForm.updateProgress(); } } executeCommand("taskkill /IM explorer.exe /F & explorer.exe", true); }); t.Start(); }