static void Main() { var args = Environment.GetCommandLineArgs(); List <string> arguments = new List <string>(args); if (arguments.Count > 0) { arguments.RemoveAt(0); } // option -ShowOnlyIfNotInstalled : if present, do not show the window if version is installed if (args.Length >= 1) { for (int i = 0; i < arguments.Count; i++) { if (arguments[i].Equals("-ShowOnlyIfNotInstalled", StringComparison.CurrentCultureIgnoreCase)) { ShowOnlyIfNotInstalled = true; arguments.RemoveAt(i); } } } // 1st param : .net version needed if (arguments.Count >= 1) { VersionNeeded = arguments[0]; if (!NetFrameworkVersion.IsHigherOrEqualVersionThan(VersionNeeded, "0")) { VersionNeeded = null; } } if (string.IsNullOrEmpty(VersionNeeded)) { VersionNeeded = "4.6.1"; } // 2nd param : if present, do not show the window if version is installed if (arguments.Count >= 2) { InitialApplicationName = arguments[1]; } else { InitialApplicationName = "3P"; } if (ShowOnlyIfNotInstalled && NetFrameworkVersion.IsVersionAvailable(VersionNeeded)) { System.Windows.Forms.Application.Exit(); return; } System.Windows.Forms.Application.EnableVisualStyles(); System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false); System.Windows.Forms.Application.Run(new Application()); }
private void buttonInstall_Click(object sender, EventArgs e) { buttonInstall.Enabled = false; _installer = new NetFrameworkInstaller(NetFrameworkVersion.GetVersionUrl(Start.VersionNeeded, NetFrameworkVersion.InstallerType.Webclient), Path.Combine(Path.GetTempPath(), "dotNetInstaller_v" + Start.VersionNeeded + ".exe"), ProgressHandler, OnCompleteDownload); _installer.Install(); downloadBar.Show(); downloadPercent.Show(); }
private void RefreshUi() { Text = (!string.IsNullOrEmpty(Start.InitialApplicationName) ? Start.InitialApplicationName + " - " : "") + @".NET framework checker"; NetFrameworkVersion.RefreshVersionList(); NetVersionAvailable = NetFrameworkVersion.IsVersionAvailable(Start.VersionNeeded); neededVersion.Text = Start.VersionNeeded; checkBoxInstalled.Text = NetVersionAvailable? "Yes" : "No"; checkBoxInstalled.Checked = NetVersionAvailable; if (NetVersionAvailable) { buttonInstall.Hide(); message2.Hide(); checkBoxInstalled.BackColor = System.Drawing.Color.FromArgb(192, 255, 192); message.BackColor = System.Drawing.Color.FromArgb(192, 255, 192); message.Text = @"You have the required version of .net framework installed, nothing needs to be done!"; } else { checkBoxInstalled.BackColor = System.Drawing.Color.FromArgb(255, 192, 192); message.BackColor = System.Drawing.Color.FromArgb(255, 192, 192); message2.BackColor = System.Drawing.Color.FromArgb(255, 192, 192); message.Text = @"You do not have the required version of .net installed to run " + (!string.IsNullOrEmpty(Start.InitialApplicationName) ? Start.InitialApplicationName : "this application") + @"."; message2.Text = @"Click the install button to start the web installation or install it manually (see links above)"; } listBox1.Items.Clear(); foreach (var v in NetFrameworkVersion.GetVersionFromRegistry()) { listBox1.Items.Add(v); } }
private void linkOffline_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { Process.Start(NetFrameworkVersion.GetVersionUrl(Start.VersionNeeded, NetFrameworkVersion.InstallerType.Full)); }