fix updater, fix multiple crashes
This commit is contained in:
parent
051c4df2b6
commit
7169325e7e
3 changed files with 33 additions and 12 deletions
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows;
|
||||
|
@ -17,7 +18,7 @@ namespace EnvyUpdate
|
|||
private string localDriv = null;
|
||||
private string onlineDriv = null;
|
||||
private string gpuURL = null;
|
||||
private string argument = null;
|
||||
private string[] arguments = null;
|
||||
private bool isDebug = false;
|
||||
|
||||
public MainWindow()
|
||||
|
@ -27,7 +28,7 @@ namespace EnvyUpdate
|
|||
// Try to get command line arguments
|
||||
try
|
||||
{
|
||||
argument = Environment.GetCommandLineArgs()[1];
|
||||
arguments = Environment.GetCommandLineArgs();
|
||||
}
|
||||
catch (IndexOutOfRangeException)
|
||||
{
|
||||
|
@ -42,7 +43,8 @@ namespace EnvyUpdate
|
|||
}
|
||||
|
||||
// Delete installed legacy versions
|
||||
UninstallAll();
|
||||
if (Directory.Exists(GlobalVars.appdata))
|
||||
UninstallAll();
|
||||
|
||||
GlobalVars.isMobile = Util.IsMobile();
|
||||
|
||||
|
@ -63,7 +65,7 @@ namespace EnvyUpdate
|
|||
}
|
||||
else
|
||||
{
|
||||
if (argument == "/debug")
|
||||
if (arguments.Contains("/debug"))
|
||||
{
|
||||
MessageBox.Show("Debug mode!");
|
||||
isDebug = true;
|
||||
|
@ -75,6 +77,20 @@ namespace EnvyUpdate
|
|||
}
|
||||
}
|
||||
|
||||
// Check for startup shortcut
|
||||
if (File.Exists(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Startup), "EnvyUpdate.lnk")))
|
||||
{
|
||||
chkAutostart.IsChecked = true;
|
||||
chkAutostart_Click(null, null); //Automatically recreate shortcut to account for moved EXE.
|
||||
}
|
||||
|
||||
//Check if launched as miminized with arg
|
||||
if (arguments.Contains("/minimize"))
|
||||
{
|
||||
WindowState = WindowState.Minimized;
|
||||
Hide();
|
||||
}
|
||||
|
||||
DispatcherTimer Dt = new DispatcherTimer();
|
||||
Dt.Tick += new EventHandler(Dt_Tick);
|
||||
// Check for new updates every 5 hours.
|
||||
|
@ -177,12 +193,6 @@ namespace EnvyUpdate
|
|||
else
|
||||
textblockOnline.Foreground = Brushes.Green;
|
||||
}
|
||||
|
||||
if (GlobalVars.exepath == GlobalVars.appdata)
|
||||
{
|
||||
WindowState = WindowState.Minimized;
|
||||
Hide();
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonDL_Click(object sender, RoutedEventArgs e)
|
||||
|
@ -253,7 +263,14 @@ namespace EnvyUpdate
|
|||
|
||||
private void chkAutostart_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
MessageBox.Show("TEST");
|
||||
if (File.Exists(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Startup), "EnvyUpdate.lnk")))
|
||||
{
|
||||
File.Delete(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Startup), "EnvyUpdate.lnk"));
|
||||
}
|
||||
if (chkAutostart.IsChecked == true)
|
||||
{
|
||||
Util.CreateShortcut("EnvyUpdate", Environment.GetFolderPath(Environment.SpecialFolder.Startup), GlobalVars.exeloc, "NVidia Update Checker", "/minimize");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -58,13 +58,15 @@ namespace EnvyUpdate
|
|||
/// <param name="shortcutPath"></param>
|
||||
/// <param name="targetFileLocation"></param>
|
||||
/// <param name="description"></param>
|
||||
public static void CreateShortcut(string shortcutName, string shortcutPath, string targetFileLocation, string description)
|
||||
/// <param name="arguments"></param>
|
||||
public static void CreateShortcut(string shortcutName, string shortcutPath, string targetFileLocation, string description, string arguments = "")
|
||||
{
|
||||
// It seems unnecessarily complex to create a simple shortcut using C#. Oh well.
|
||||
string shortcutLocation = Path.Combine(shortcutPath, shortcutName + ".lnk");
|
||||
WshShell shell = new WshShell();
|
||||
IWshShortcut shortcut = (IWshShortcut)shell.CreateShortcut(shortcutLocation);
|
||||
|
||||
shortcut.Arguments = arguments;
|
||||
shortcut.Description = description;
|
||||
shortcut.TargetPath = targetFileLocation;
|
||||
shortcut.Save();
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
|
||||
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.
|
||||
|
||||
Enabling Autostart will create a shortcut of EnvyUpdate in the Windows startup folder.
|
||||
|
||||
## Compatibility
|
||||
|
||||
The application should be compatible with all Nvidia GPUs that have their drivers available on the nvidia.com download page and runs on Windows 7 and up.
|
||||
|
|
Reference in a new issue