diff --git a/EnvyUpdate/MainWindow.xaml.cs b/EnvyUpdate/MainWindow.xaml.cs
index dc683d6..1204619 100644
--- a/EnvyUpdate/MainWindow.xaml.cs
+++ b/EnvyUpdate/MainWindow.xaml.cs
@@ -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");
+ }
}
}
}
\ No newline at end of file
diff --git a/EnvyUpdate/Util.cs b/EnvyUpdate/Util.cs
index ab0ed62..c2173e6 100644
--- a/EnvyUpdate/Util.cs
+++ b/EnvyUpdate/Util.cs
@@ -58,13 +58,15 @@ namespace EnvyUpdate
///
///
///
- public static void CreateShortcut(string shortcutName, string shortcutPath, string targetFileLocation, string description)
+ ///
+ 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();
diff --git a/README.md b/README.md
index 028757a..e95387d 100644
--- a/README.md
+++ b/README.md
@@ -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.