diff --git a/EnvyUpdate/DashboardPage.xaml.cs b/EnvyUpdate/DashboardPage.xaml.cs index 5501dbd..2eadc5a 100644 --- a/EnvyUpdate/DashboardPage.xaml.cs +++ b/EnvyUpdate/DashboardPage.xaml.cs @@ -8,7 +8,6 @@ using System.Text.RegularExpressions; using System.Threading; using System.Windows; using System.Windows.Threading; -using Wpf.Ui.Controls; using MessageBox = System.Windows.MessageBox; namespace EnvyUpdate @@ -363,11 +362,13 @@ namespace EnvyUpdate File.Delete(Path.Combine(GlobalVars.exedirectory, onlineDriv + "-nvidia-installer.exe.downloading")); } Thread thread = new Thread(() => { - WebClient client = new WebClient(); - client.Headers["User-Agent"] = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:115.0) Gecko/20100101 Firefox/115.0"; - client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(client_DownloadProgressChanged); - client.DownloadFileCompleted += new AsyncCompletedEventHandler(client_DownloadFileCompleted); - client.DownloadFileAsync(new Uri(Util.GetDirectDownload(gpuURL)), Path.Combine(GlobalVars.exedirectory, onlineDriv + "-nvidia-installer.exe.downloading")); + using (WebClient client = new WebClient()) + { + client.Headers["User-Agent"] = GlobalVars.useragent; + client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(client_DownloadProgressChanged); + client.DownloadFileCompleted += new AsyncCompletedEventHandler(client_DownloadFileCompleted); + client.DownloadFileAsync(new Uri(Util.GetDirectDownload(gpuURL)), Path.Combine(GlobalVars.exedirectory, onlineDriv + "-nvidia-installer.exe.downloading")); + } }); thread.Start(); Debug.LogToFile("INFO Started installer download."); @@ -391,7 +392,7 @@ namespace EnvyUpdate if (e.Error == null) { Application.Current.Dispatcher.Invoke(new Action(() => { - showSnackbar(Wpf.Ui.Common.ControlAppearance.Success, Wpf.Ui.Common.SymbolRegular.CheckmarkCircle24, Properties.Resources.info_download_success, Properties.Resources.info_download_success_title); + ShowSnackbar(Wpf.Ui.Common.ControlAppearance.Success, Wpf.Ui.Common.SymbolRegular.CheckmarkCircle24, Properties.Resources.info_download_success, Properties.Resources.info_download_success_title); buttonDownload.Visibility = Visibility.Collapsed; buttonInstall.Visibility = Visibility.Visible; Debug.LogToFile("INFO Download successful."); @@ -404,17 +405,73 @@ namespace EnvyUpdate { File.Delete(Path.Combine(GlobalVars.exedirectory, onlineDriv + "-nvidia-installer.exe.downloading")); Application.Current.Dispatcher.Invoke(new Action(() => { - showSnackbar(Wpf.Ui.Common.ControlAppearance.Danger, Wpf.Ui.Common.SymbolRegular.ErrorCircle24, Properties.Resources.info_download_error, Properties.Resources.info_download_error_title); + ShowSnackbar(Wpf.Ui.Common.ControlAppearance.Danger, Wpf.Ui.Common.SymbolRegular.ErrorCircle24, Properties.Resources.info_download_error, Properties.Resources.info_download_error_title); Debug.LogToFile("INFO Download NOT successful. Error: " + e.Error.ToString()); })); } } private void buttonInstall_Click(object sender, RoutedEventArgs e) { + string sevenZipPath = Util.GetSevenZip(); + ShowSnackbar(Wpf.Ui.Common.ControlAppearance.Info, Wpf.Ui.Common.SymbolRegular.FolderZip24, Properties.Resources.info_extracting, Properties.Resources.info_extracting_title); + + string filePath = Path.Combine(GlobalVars.exedirectory, onlineDriv + "-nvidia-installer.exe"); + string destinationDir = Path.Combine(GlobalVars.exedirectory, onlineDriv + "-extracted"); + + if (!Directory.Exists(destinationDir)) + Directory.CreateDirectory(destinationDir); + + Process process = new Process(); + ProcessStartInfo startInfo = new ProcessStartInfo + { + WindowStyle = ProcessWindowStyle.Minimized, + WorkingDirectory = destinationDir, + FileName = sevenZipPath, + Arguments = "x -aoa -y " + filePath + " Display.Driver Display.Nview Display.Optimus HDAudio MSVCR NVI2 NVPCF PhysX PPC ShieldWirelessController EULA.txt ListDevices.txt setup.cfg setup.exe" + }; + process.EnableRaisingEvents = true; + process.StartInfo = startInfo; + process.Exited += new EventHandler(ExtractionFinished); + process.Start(); } - private void showSnackbar (Wpf.Ui.Common.ControlAppearance appearance, Wpf.Ui.Common.SymbolRegular icon, string message = "", string title = "") + private void ExtractionFinished(object sender, EventArgs e) + { + string extractedPath = Path.Combine(GlobalVars.exedirectory, onlineDriv + "-extracted"); + Application.Current.Dispatcher.Invoke(new Action(() => { + ShowSnackbar(Wpf.Ui.Common.ControlAppearance.Success, Wpf.Ui.Common.SymbolRegular.FolderZip24, Properties.Resources.info_extract_complete, Properties.Resources.info_extract_complete_title); + })); + + File.Delete(Path.Combine(GlobalVars.exedirectory, "7zr.exe")); + + Util.CleanInstallConfig(Path.Combine(extractedPath, "setup.cfg")); + + Process process = new Process(); + ProcessStartInfo startInfo = new ProcessStartInfo + { + WindowStyle = ProcessWindowStyle.Normal, + WorkingDirectory = extractedPath, + FileName = "setup.exe", + Arguments = "-passive -noreboot -noeula" + }; + process.EnableRaisingEvents = true; + process.StartInfo = startInfo; + process.Exited += new EventHandler(InstallFinished); + process.Start(); + } + + private void InstallFinished(object sender, EventArgs e) + { + Application.Current.Dispatcher.Invoke(new Action(() => { + ShowSnackbar(Wpf.Ui.Common.ControlAppearance.Success, Wpf.Ui.Common.SymbolRegular.FolderZip24, Properties.Resources.info_install_complete, Properties.Resources.info_install_complete_title); + })); + + File.Delete(Path.Combine(GlobalVars.exedirectory, onlineDriv + "-nvidia-installer.exe")); + Directory.Delete(Path.Combine(GlobalVars.exedirectory, onlineDriv + "-extracted"), true); + } + + private void ShowSnackbar(Wpf.Ui.Common.ControlAppearance appearance, Wpf.Ui.Common.SymbolRegular icon, string message = "", string title = "") { snackbarInfo.Appearance = appearance; snackbarInfo.Icon = icon; diff --git a/EnvyUpdate/EnvyUpdate.csproj b/EnvyUpdate/EnvyUpdate.csproj index 29dd347..894b162 100644 --- a/EnvyUpdate/EnvyUpdate.csproj +++ b/EnvyUpdate/EnvyUpdate.csproj @@ -240,7 +240,7 @@ 4.1.0 - 6.6.4 + 6.8.0 runtime; build; native; contentfiles; analyzers; buildtransitive all @@ -251,10 +251,10 @@ 2.2.0 - 7.0.1 + 7.0.3 - 2.0.3 + 2.1.0 diff --git a/EnvyUpdate/GlobalVars.cs b/EnvyUpdate/GlobalVars.cs index 249bb54..e9d8b9b 100644 --- a/EnvyUpdate/GlobalVars.cs +++ b/EnvyUpdate/GlobalVars.cs @@ -12,5 +12,6 @@ namespace EnvyUpdate public static readonly string appdata = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\envyupdate\\"; public static readonly string startup = Environment.GetFolderPath(Environment.SpecialFolder.Startup); public static bool monitoringInstall = false; + public static readonly string useragent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:115.0) Gecko/20100101 Firefox/115.0"; } } diff --git a/EnvyUpdate/Properties/Licenses.Designer.cs b/EnvyUpdate/Properties/Licenses.Designer.cs index 5c0056d..4acc90b 100644 --- a/EnvyUpdate/Properties/Licenses.Designer.cs +++ b/EnvyUpdate/Properties/Licenses.Designer.cs @@ -120,6 +120,21 @@ namespace EnvyUpdate.Properties { } } + /// + /// Looks up a localized string similar to MIT License + /// + ///Copyright (c) 2017 Alexander Selishchev + /// + ///Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + /// + ///The above copyrigh [rest of string was truncated]";. + /// + internal static string SevenZipExtractor { + get { + return ResourceManager.GetString("SevenZipExtractor", resourceCulture); + } + } + /// /// Looks up a localized string similar to # Windows Community Toolkit /// diff --git a/EnvyUpdate/Properties/Licenses.resx b/EnvyUpdate/Properties/Licenses.resx index 6ebf13d..be5631f 100644 --- a/EnvyUpdate/Properties/Licenses.resx +++ b/EnvyUpdate/Properties/Licenses.resx @@ -159,6 +159,17 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + + MIT License + +Copyright (c) 2017 Alexander Selishchev + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/EnvyUpdate/Properties/Resources.Designer.cs b/EnvyUpdate/Properties/Resources.Designer.cs index 6cac9c1..727d269 100644 --- a/EnvyUpdate/Properties/Resources.Designer.cs +++ b/EnvyUpdate/Properties/Resources.Designer.cs @@ -69,6 +69,15 @@ namespace EnvyUpdate.Properties { } } + /// + /// Looks up a localized string similar to An error occurred attempting to install the new version. Please enable logging in the settings and report the issue on GitHub!. + /// + public static string error_installing { + get { + return ResourceManager.GetString("error_installing", resourceCulture); + } + } + /// /// Looks up a localized string similar to Exit EnvyUpdate?. /// @@ -114,6 +123,60 @@ namespace EnvyUpdate.Properties { } } + /// + /// Looks up a localized string similar to The driver files have finished extracting.. + /// + public static string info_extract_complete { + get { + return ResourceManager.GetString("info_extract_complete", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Extraction complete. + /// + public static string info_extract_complete_title { + get { + return ResourceManager.GetString("info_extract_complete_title", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The driver files are being extracted. This could take a few minutes.. + /// + public static string info_extracting { + get { + return ResourceManager.GetString("info_extracting", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Extracting driver files. + /// + public static string info_extracting_title { + get { + return ResourceManager.GetString("info_extracting_title", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The installation of the new driver version was completed.. + /// + public static string info_install_complete { + get { + return ResourceManager.GetString("info_install_complete", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Update finished. + /// + public static string info_install_complete_title { + get { + return ResourceManager.GetString("info_install_complete_title", resourceCulture); + } + } + /// /// Looks up a localized string similar to Preference reset.. /// diff --git a/EnvyUpdate/Properties/Resources.de.resx b/EnvyUpdate/Properties/Resources.de.resx index 7758b15..6a71fa2 100644 --- a/EnvyUpdate/Properties/Resources.de.resx +++ b/EnvyUpdate/Properties/Resources.de.resx @@ -120,6 +120,9 @@ NVIDIA Aktualisierungsanwendung. + + Ein Fehler ist bei der Installation aufgetreten. Bitte aktivieren Sie den Log und melden Sie den Fehler auf GitHub! + EnvyUpdate schließen? @@ -135,6 +138,24 @@ Herunterladen erfolgreich abgeschlossen + + Die Treiberdateien werden nun extrahiert. Dies könnte einige Minuten dauern. + + + Dateien werden extrahiert + + + Die Treiberdateien wurden vollständig extrahiert. + + + Extrahierung abgeschlossen + + + Die Installation der neuen Treiberversion wurde abgeschlossen. + + + Update abgeschlossen + Einstellung zurückgesetzt. diff --git a/EnvyUpdate/Properties/Resources.resx b/EnvyUpdate/Properties/Resources.resx index 8667646..63c8453 100644 --- a/EnvyUpdate/Properties/Resources.resx +++ b/EnvyUpdate/Properties/Resources.resx @@ -120,6 +120,9 @@ NVIDIA Updater Application. + + An error occurred attempting to install the new version. Please enable logging in the settings and report the issue on GitHub! + Exit EnvyUpdate? @@ -135,6 +138,24 @@ Download successful + + The driver files are being extracted. This could take a few minutes. + + + Extracting driver files + + + The driver files have finished extracting. + + + Extraction complete + + + The installation of the new driver version was completed. + + + Update finished + Preference reset. diff --git a/EnvyUpdate/SettingsPage.xaml b/EnvyUpdate/SettingsPage.xaml index b707a27..f01e838 100644 --- a/EnvyUpdate/SettingsPage.xaml +++ b/EnvyUpdate/SettingsPage.xaml @@ -49,6 +49,9 @@ + + + diff --git a/EnvyUpdate/SettingsPage.xaml.cs b/EnvyUpdate/SettingsPage.xaml.cs index 28fe8b7..bede45d 100644 --- a/EnvyUpdate/SettingsPage.xaml.cs +++ b/EnvyUpdate/SettingsPage.xaml.cs @@ -28,6 +28,7 @@ namespace EnvyUpdate textBoxLicFody.Text = Properties.Licenses.Fody; textBoxLicCostura.Text = Properties.Licenses.CosturaFody; textBoxLicResourceembedder.Text = Properties.Licenses.ResourceEmbedder; + textBoxLic7z.Text = Properties.Licenses.SevenZipExtractor; textBoxLicWindowscommunitytoolkit.Text = Properties.Licenses.WindowsCommunityToolkit; textBoxLicWpfui.Text = Properties.Licenses.wpfui; } diff --git a/EnvyUpdate/Util.cs b/EnvyUpdate/Util.cs index 2b03540..5c41283 100644 --- a/EnvyUpdate/Util.cs +++ b/EnvyUpdate/Util.cs @@ -1,5 +1,4 @@ -using EnvyUpdate.Properties; -using IWshRuntimeLibrary; +using IWshRuntimeLibrary; using Microsoft.Win32; using System; using System.Diagnostics; @@ -8,9 +7,7 @@ using System.Linq; using System.Management; using System.Net; using System.Text.RegularExpressions; -using System.Threading.Tasks; using System.Windows; -using System.Windows.Controls; using System.Xml.Linq; namespace EnvyUpdate @@ -576,5 +573,74 @@ namespace EnvyUpdate directUrl = "https://us.download.nvidia.com" + directUrl; return directUrl; } + + public static string GetSevenZip() + { + // Note: This download happens on the main thread. I believe spinning up a whole thread to + // download a single 600kb file is less efficient than just doing it on the main thread. + // At 1Mbit/s, this download takes 5 seconds, in most cases internet should be faster than that. + string path = Path.Combine(GlobalVars.exedirectory, "7zr.exe"); + using (WebClient client = new WebClient()) + { + client.Headers["User-Agent"] = GlobalVars.useragent; + client.DownloadFile(new Uri("https://www.7-zip.org/a/7zr.exe"), path); + } + + return path; + } + + public static Process ExtractWithSevenZip(string sevenZipPath, string filePath, string destinationDir) + { + if (!Directory.Exists(destinationDir)) + Directory.CreateDirectory(destinationDir); + + Process process = new Process(); + ProcessStartInfo startInfo = new ProcessStartInfo + { + WindowStyle = ProcessWindowStyle.Minimized, + WorkingDirectory = destinationDir, + FileName = sevenZipPath, + Arguments = "x -aoa -y " + filePath + " Display.Driver Display.Nview Display.Optimus HDAudio MSVCR NVI2 NVPCF PhysX PPC ShieldWirelessController EULA.txt ListDevices.txt setup.cfg setup.exe" + }; + process.EnableRaisingEvents = true; + process.StartInfo = startInfo; + return process; + } + + public static void CleanInstallConfig(string filePath) + { + if (!System.IO.File.Exists(filePath)) + { + Debug.LogToFile("FATAL Driver installer config not found, terminating."); + MessageBox.Show(Properties.Resources.error_installing); + Environment.Exit(17); + } + + Debug.LogToFile("INFO Removing GFE content from installer config."); + + string outfile = filePath + ".out"; + + StreamReader sr = new StreamReader(filePath); + StreamWriter sw = new StreamWriter(outfile); + string line; + + while ((line = sr.ReadLine()) != null) + { + if (new[] { "EulaHtmlFile", "FunctionalConsentFile", "PrivacyPolicyFile" }.Any(c => line.Contains(c))) + { + continue; + } + + sw.WriteLine(line); + } + + sw.Close(); + sr.Close(); + + System.IO.File.Delete(filePath); + System.IO.File.Move(outfile, filePath); + + Debug.LogToFile("INFO Finished removing GFE content from installer config."); + } } } diff --git a/README.md b/README.md index 2b6a970..51ea1ea 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,7 @@ EnvyUpdate is not a replacement for any of these tools. I will still try to impl * Fody (dependency of Costura.Fody): [MIT](https://github.com/Fody/Fody/blob/master/License.txt) * Costura.Fody (for embedding DLLs into the main executable): [MIT](https://github.com/Fody/Costura/blob/develop/LICENSE) * Resource Embedder: [MIT](https://www.nuget.org/packages/Resource.Embedder/) +* SevenZipExtractor: [MIT](https://github.com/adoconnection/SevenZipExtractor/blob/master/LICENSE) * Windows Community Toolkit: [MIT](https://github.com/CommunityToolkit/WindowsCommunityToolkit/blob/main/License.md) * wpfui: [MIT](https://github.com/lepoco/wpfui/blob/main/LICENSE) * Icon made by Freepik from www.flaticon.com diff --git a/README.md.backup b/README.md.backup new file mode 100644 index 0000000..2b6a970 --- /dev/null +++ b/README.md.backup @@ -0,0 +1,55 @@ +![Logo](https://github.com/fyr77/envyupdate/blob/master/res/banner_bg.png?raw=true) + +# Important Information + +Nvidia has discontinued non-DCH drivers. This means only Windows 10 and Windows 11 can get the most recent driver versions. + +If you are running Standard (non-DCH) drivers right now, EnvyUpdate will **NOT** display newer driver versions until you have manually updated to DCH drivers. + +# EnvyUpdate + A small portable update checker application for Nvidia GPUs + + ![License](https://img.shields.io/github/license/fyr77/envyupdate?style=for-the-badge) + ![Issues](https://img.shields.io/github/issues/fyr77/envyupdate?style=for-the-badge) + ![Version](https://img.shields.io/github/v/release/fyr77/envyupdate?style=for-the-badge) + +## How to use + +Download the [latest release](https://github.com/fyr77/EnvyUpdate/releases/latest/download/EnvyUpdate.exe) (or as a [.zip](https://github.com/fyr77/EnvyUpdate/releases/latest/download/EnvyUpdate.zip)) and run it. Windows SmartScreen Messages can be safely ignored. They only happen because this project is not digitally signed. + +The application itself does not update itself. If you notice any bugs or issues, be sure to check for a new version on GitHub! + +Enabling Autostart will create a shortcut of EnvyUpdate in the Windows startup folder. + +## Compatibility + +The application should be compatible with all Nvidia GeForce GPUs that have their drivers available on the nvidia.com download page and runs on Windows 10 and up. + +It is tested with GeForce Series GPUs. Generally others might work, but they are (currently) untested. + +## Development + +This application is currently maintained and developed by me (fyr77) alone in my free time. + +I always try to implement critical fixes as fast as I can, but other features and minor bug fixes may take a few days or weeks to implement. + +If you want to help me develop EnvyUpdate, you can start by creating issues with your bug reports and/or feature requests. Pull requests are also welcome, especially regarding translations. + +## Other interesting tools + +* [TinyNvidiaUpdateChecker](https://github.com/ElPumpo/TinyNvidiaUpdateChecker) - a command line update checker and installer. Inspired EnvyUpdate to begin with. +* [nvidia-update](https://github.com/ZenitH-AT/nvidia-update) - a Powershell script to check for driver updates +* [Disable-Nvidia-Telemetry](https://github.com/NateShoffner/Disable-Nvidia-Telemetry) - does pretty much what the name says. It disables Nvidia Telemetry. +* [NVCleanInstall](https://www.techpowerup.com/nvcleanstall/) - a closed-source application by TechPowerUp which does quite a lot of cool things. + +EnvyUpdate is not a replacement for any of these tools. I will still try to implement as many features in EnvyUpdate as possible while keeping the simple interface and as little settings as possible. + +## Licenses + +* This project: [MIT](https://github.com/fyr77/EnvyUpdate/blob/master/LICENSE) +* Fody (dependency of Costura.Fody): [MIT](https://github.com/Fody/Fody/blob/master/License.txt) +* Costura.Fody (for embedding DLLs into the main executable): [MIT](https://github.com/Fody/Costura/blob/develop/LICENSE) +* Resource Embedder: [MIT](https://www.nuget.org/packages/Resource.Embedder/) +* Windows Community Toolkit: [MIT](https://github.com/CommunityToolkit/WindowsCommunityToolkit/blob/main/License.md) +* wpfui: [MIT](https://github.com/lepoco/wpfui/blob/main/LICENSE) +* Icon made by Freepik from www.flaticon.com