add ability to save to appdata
This commit is contained in:
parent
e932255f59
commit
babc550b6d
11 changed files with 160 additions and 56 deletions
|
@ -77,11 +77,11 @@
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<ui:CardControl Margin="0,12,0,0" Grid.Row="4" Icon="Color24" Header="Studio Driver">
|
<ui:CardControl Margin="0,12,0,0" Grid.Row="4" Icon="Color24" Header="Studio Driver">
|
||||||
<ui:ToggleSwitch x:Name="switchStudioDriver" IsChecked="False" Checked="switchStudioDriver_Checked" Unchecked="switchStudioDriver_Unchecked" />
|
<ui:ToggleSwitch x:Name="switchStudioDriver" Checked="switchStudioDriver_Checked" Unchecked="switchStudioDriver_Unchecked" />
|
||||||
</ui:CardControl>
|
</ui:CardControl>
|
||||||
|
|
||||||
<ui:CardControl Margin="0,12,0,0" Grid.Row="5" Icon="LightbulbFilament48" Header="{x:Static p:Resources.ui_autostart}">
|
<ui:CardControl Margin="0,12,0,0" Grid.Row="5" Icon="LightbulbFilament48" Header="{x:Static p:Resources.ui_autostart}">
|
||||||
<ui:ToggleSwitch x:Name="switchAutostart" IsChecked="False" Click="switchAutostart_Click" />
|
<ui:ToggleSwitch x:Name="switchAutostart" Click="switchAutostart_Click" />
|
||||||
</ui:CardControl>
|
</ui:CardControl>
|
||||||
</Grid>
|
</Grid>
|
||||||
<ui:Snackbar x:Name="snackbarInfo" Timeout="0"/>
|
<ui:Snackbar x:Name="snackbarInfo" Timeout="0"/>
|
||||||
|
|
|
@ -112,10 +112,10 @@ namespace EnvyUpdate
|
||||||
switchStudioDriver.IsChecked = false;
|
switchStudioDriver.IsChecked = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (File.Exists(GlobalVars.exedirectory + "skip.envy"))
|
if (File.Exists(Path.Combine(GlobalVars.saveDirectory,"skip.envy")))
|
||||||
{
|
{
|
||||||
Debug.LogToFile("INFO Found version skip config.");
|
Debug.LogToFile("INFO Found version skip config.");
|
||||||
skippedVer = File.ReadLines(GlobalVars.exedirectory + "skip.envy").First();
|
skippedVer = File.ReadLines(Path.Combine(GlobalVars.saveDirectory, "skip.envy")).First();
|
||||||
}
|
}
|
||||||
|
|
||||||
// This little bool check is necessary for debug fake mode.
|
// This little bool check is necessary for debug fake mode.
|
||||||
|
@ -137,9 +137,9 @@ namespace EnvyUpdate
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// disable SD and try with GRD
|
// disable SD and try with GRD
|
||||||
if (File.Exists(GlobalVars.exedirectory + "sd.envy"))
|
if (File.Exists(Path.Combine(GlobalVars.saveDirectory, "sd.envy")))
|
||||||
{
|
{
|
||||||
File.Delete(GlobalVars.exedirectory + "sd.envy");
|
File.Delete(Path.Combine(GlobalVars.saveDirectory, "sd.envy"));
|
||||||
}
|
}
|
||||||
|
|
||||||
gpuURL = Util.GetGpuUrl(); //try again with GRD
|
gpuURL = Util.GetGpuUrl(); //try again with GRD
|
||||||
|
@ -226,15 +226,15 @@ namespace EnvyUpdate
|
||||||
{
|
{
|
||||||
Debug.LogToFile("INFO Skipped version is surpassed, deleting setting.");
|
Debug.LogToFile("INFO Skipped version is surpassed, deleting setting.");
|
||||||
skippedVer = null;
|
skippedVer = null;
|
||||||
if (File.Exists(GlobalVars.exedirectory + "skip.envy"))
|
if (File.Exists(Path.Combine(GlobalVars.saveDirectory, "skip.envy")))
|
||||||
File.Delete(GlobalVars.exedirectory + "skip.envy");
|
File.Delete(Path.Combine(GlobalVars.saveDirectory, "skip.envy"));
|
||||||
buttonSkipVersion.ToolTip = Properties.Resources.ui_skipversion;
|
buttonSkipVersion.ToolTip = Properties.Resources.ui_skipversion;
|
||||||
buttonSkipVersion.IsEnabled = true;
|
buttonSkipVersion.IsEnabled = true;
|
||||||
buttonSkipVersion.Visibility = Visibility.Visible;
|
buttonSkipVersion.Visibility = Visibility.Visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if update file already exists and display install button instead
|
// Check if update file already exists and display install button instead
|
||||||
if (File.Exists(Path.Combine(GlobalVars.exedirectory, onlineDriv + "-nvidia-installer.exe")))
|
if (File.Exists(Path.Combine(GlobalVars.saveDirectory, onlineDriv + "-nvidia-installer.exe")))
|
||||||
{
|
{
|
||||||
Debug.LogToFile("INFO Found downloaded driver installer, no need to redownload.");
|
Debug.LogToFile("INFO Found downloaded driver installer, no need to redownload.");
|
||||||
buttonDownload.Visibility = Visibility.Collapsed;
|
buttonDownload.Visibility = Visibility.Collapsed;
|
||||||
|
@ -244,20 +244,20 @@ namespace EnvyUpdate
|
||||||
|
|
||||||
private void switchStudioDriver_Unchecked(object sender, RoutedEventArgs e)
|
private void switchStudioDriver_Unchecked(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
if (File.Exists(GlobalVars.exedirectory + "sd.envy"))
|
if (File.Exists(Path.Combine(GlobalVars.saveDirectory, "sd.envy")))
|
||||||
{
|
{
|
||||||
Debug.LogToFile("INFO Switching to game ready driver.");
|
Debug.LogToFile("INFO Switching to game ready driver.");
|
||||||
File.Delete(GlobalVars.exedirectory + "sd.envy");
|
File.Delete(Path.Combine(GlobalVars.saveDirectory, "sd.envy"));
|
||||||
Load();
|
Load();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void switchStudioDriver_Checked(object sender, RoutedEventArgs e)
|
private void switchStudioDriver_Checked(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
if (!File.Exists(GlobalVars.exedirectory + "sd.envy"))
|
if (!File.Exists(Path.Combine(GlobalVars.saveDirectory, "sd.envy")))
|
||||||
{
|
{
|
||||||
Debug.LogToFile("INFO Switching to studio driver.");
|
Debug.LogToFile("INFO Switching to studio driver.");
|
||||||
File.Create(GlobalVars.exedirectory + "sd.envy").Close();
|
File.Create(Path.Combine(GlobalVars.saveDirectory, "sd.envy")).Close();
|
||||||
Load();
|
Load();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -272,7 +272,7 @@ namespace EnvyUpdate
|
||||||
if (switchAutostart.IsChecked == true)
|
if (switchAutostart.IsChecked == true)
|
||||||
{
|
{
|
||||||
Debug.LogToFile("INFO Creating autostart entry.");
|
Debug.LogToFile("INFO Creating autostart entry.");
|
||||||
Util.CreateShortcut("EnvyUpdate", Environment.GetFolderPath(Environment.SpecialFolder.Startup), GlobalVars.exeloc, "NVidia Update Checker", "/minimize");
|
Util.CreateShortcut("EnvyUpdate", Environment.GetFolderPath(Environment.SpecialFolder.Startup), GlobalVars.pathToAppExe, "NVidia Update Checker", "/minimize");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -280,7 +280,7 @@ namespace EnvyUpdate
|
||||||
{
|
{
|
||||||
Debug.LogToFile("INFO Skipping version.");
|
Debug.LogToFile("INFO Skipping version.");
|
||||||
skippedVer = onlineDriv;
|
skippedVer = onlineDriv;
|
||||||
File.WriteAllText(GlobalVars.exedirectory + "skip.envy", onlineDriv);
|
File.WriteAllText(Path.Combine(GlobalVars.saveDirectory, "skip.envy"), onlineDriv);
|
||||||
buttonSkipVersion.IsEnabled = false;
|
buttonSkipVersion.IsEnabled = false;
|
||||||
buttonSkipVersion.ToolTip = Properties.Resources.ui_skipped;
|
buttonSkipVersion.ToolTip = Properties.Resources.ui_skipped;
|
||||||
MessageBox.Show(Properties.Resources.skip_confirm);
|
MessageBox.Show(Properties.Resources.skip_confirm);
|
||||||
|
@ -343,10 +343,10 @@ namespace EnvyUpdate
|
||||||
progressbarDownload.Visibility = Visibility.Visible;
|
progressbarDownload.Visibility = Visibility.Visible;
|
||||||
buttonDownload.IsEnabled = false;
|
buttonDownload.IsEnabled = false;
|
||||||
|
|
||||||
if (File.Exists(Path.Combine(GlobalVars.exedirectory, onlineDriv + "-nvidia-installer.exe.downloading")))
|
if (File.Exists(Path.Combine(GlobalVars.saveDirectory, onlineDriv + "-nvidia-installer.exe.downloading")))
|
||||||
{
|
{
|
||||||
Debug.LogToFile("WARN Found previous unfinished download, retrying.");
|
Debug.LogToFile("WARN Found previous unfinished download, retrying.");
|
||||||
File.Delete(Path.Combine(GlobalVars.exedirectory, onlineDriv + "-nvidia-installer.exe.downloading"));
|
File.Delete(Path.Combine(GlobalVars.saveDirectory, onlineDriv + "-nvidia-installer.exe.downloading"));
|
||||||
}
|
}
|
||||||
Thread thread = new Thread(() => {
|
Thread thread = new Thread(() => {
|
||||||
using (WebClient client = new WebClient())
|
using (WebClient client = new WebClient())
|
||||||
|
@ -354,7 +354,7 @@ namespace EnvyUpdate
|
||||||
client.Headers["User-Agent"] = GlobalVars.useragent;
|
client.Headers["User-Agent"] = GlobalVars.useragent;
|
||||||
client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(client_DownloadProgressChanged);
|
client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(client_DownloadProgressChanged);
|
||||||
client.DownloadFileCompleted += new AsyncCompletedEventHandler(client_DownloadFileCompleted);
|
client.DownloadFileCompleted += new AsyncCompletedEventHandler(client_DownloadFileCompleted);
|
||||||
client.DownloadFileAsync(new Uri(Util.GetDirectDownload(gpuURL)), Path.Combine(GlobalVars.exedirectory, onlineDriv + "-nvidia-installer.exe.downloading"));
|
client.DownloadFileAsync(new Uri(Util.GetDirectDownload(gpuURL)), Path.Combine(GlobalVars.saveDirectory, onlineDriv + "-nvidia-installer.exe.downloading"));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
thread.Start();
|
thread.Start();
|
||||||
|
@ -385,13 +385,13 @@ namespace EnvyUpdate
|
||||||
buttonInstall.Visibility = Visibility.Visible;
|
buttonInstall.Visibility = Visibility.Visible;
|
||||||
Debug.LogToFile("INFO Download successful.");
|
Debug.LogToFile("INFO Download successful.");
|
||||||
}));
|
}));
|
||||||
if (File.Exists(Path.Combine(GlobalVars.exedirectory, onlineDriv + "-nvidia-installer.exe")))
|
if (File.Exists(Path.Combine(GlobalVars.saveDirectory, onlineDriv + "-nvidia-installer.exe")))
|
||||||
File.Delete(Path.Combine(GlobalVars.exedirectory, onlineDriv + "-nvidia-installer.exe"));
|
File.Delete(Path.Combine(GlobalVars.saveDirectory, onlineDriv + "-nvidia-installer.exe"));
|
||||||
File.Move(Path.Combine(GlobalVars.exedirectory, onlineDriv + "-nvidia-installer.exe.downloading"), Path.Combine(GlobalVars.exedirectory, onlineDriv + "-nvidia-installer.exe"));
|
File.Move(Path.Combine(GlobalVars.saveDirectory, onlineDriv + "-nvidia-installer.exe.downloading"), Path.Combine(GlobalVars.saveDirectory, onlineDriv + "-nvidia-installer.exe"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
File.Delete(Path.Combine(GlobalVars.exedirectory, onlineDriv + "-nvidia-installer.exe.downloading"));
|
File.Delete(Path.Combine(GlobalVars.saveDirectory, onlineDriv + "-nvidia-installer.exe.downloading"));
|
||||||
Application.Current.Dispatcher.Invoke(new Action(() => {
|
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());
|
Debug.LogToFile("INFO Download NOT successful. Error: " + e.Error.ToString());
|
||||||
|
@ -406,8 +406,8 @@ namespace EnvyUpdate
|
||||||
|
|
||||||
ShowSnackbar(Wpf.Ui.Common.ControlAppearance.Info, Wpf.Ui.Common.SymbolRegular.FolderZip24, Properties.Resources.info_extracting, Properties.Resources.info_extracting_title);
|
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 filePath = Path.Combine(GlobalVars.saveDirectory, onlineDriv + "-nvidia-installer.exe");
|
||||||
string destinationDir = Path.Combine(GlobalVars.exedirectory, onlineDriv + "-extracted");
|
string destinationDir = Path.Combine(GlobalVars.saveDirectory, onlineDriv + "-extracted");
|
||||||
|
|
||||||
if (!Directory.Exists(destinationDir))
|
if (!Directory.Exists(destinationDir))
|
||||||
Directory.CreateDirectory(destinationDir);
|
Directory.CreateDirectory(destinationDir);
|
||||||
|
@ -430,13 +430,13 @@ namespace EnvyUpdate
|
||||||
|
|
||||||
private void ExtractionFinished(object sender, EventArgs e)
|
private void ExtractionFinished(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
string extractedPath = Path.Combine(GlobalVars.exedirectory, onlineDriv + "-extracted");
|
string extractedPath = Path.Combine(GlobalVars.saveDirectory, onlineDriv + "-extracted");
|
||||||
Application.Current.Dispatcher.Invoke(new Action(() => {
|
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);
|
ShowSnackbar(Wpf.Ui.Common.ControlAppearance.Success, Wpf.Ui.Common.SymbolRegular.FolderZip24, Properties.Resources.info_extract_complete, Properties.Resources.info_extract_complete_title);
|
||||||
}));
|
}));
|
||||||
Debug.LogToFile("INFO Extraction exited, deleting 7-zip executable.");
|
Debug.LogToFile("INFO Extraction exited, deleting 7-zip executable.");
|
||||||
|
|
||||||
File.Delete(Path.Combine(GlobalVars.exedirectory, "7zr.exe"));
|
File.Delete(Path.Combine(GlobalVars.saveDirectory, "7zr.exe"));
|
||||||
|
|
||||||
Util.CleanInstallConfig(Path.Combine(extractedPath, "setup.cfg"));
|
Util.CleanInstallConfig(Path.Combine(extractedPath, "setup.cfg"));
|
||||||
|
|
||||||
|
@ -468,8 +468,8 @@ namespace EnvyUpdate
|
||||||
|
|
||||||
Debug.LogToFile("INFO Driver setup complete. Cleaning up setup files.");
|
Debug.LogToFile("INFO Driver setup complete. Cleaning up setup files.");
|
||||||
|
|
||||||
File.Delete(Path.Combine(GlobalVars.exedirectory, onlineDriv + "-nvidia-installer.exe"));
|
File.Delete(Path.Combine(GlobalVars.saveDirectory, onlineDriv + "-nvidia-installer.exe"));
|
||||||
Directory.Delete(Path.Combine(GlobalVars.exedirectory, onlineDriv + "-extracted"), true);
|
Directory.Delete(Path.Combine(GlobalVars.saveDirectory, onlineDriv + "-extracted"), true);
|
||||||
GlobalVars.isInstalling = false;
|
GlobalVars.isInstalling = false;
|
||||||
Application.Current.Dispatcher.Invoke(delegate
|
Application.Current.Dispatcher.Invoke(delegate
|
||||||
{
|
{
|
||||||
|
|
|
@ -15,9 +15,6 @@ namespace EnvyUpdate
|
||||||
public static bool isVerbose = false;
|
public static bool isVerbose = false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
public static string debugFile = Path.Combine(GlobalVars.exedirectory, "envyupdate.log");
|
|
||||||
|
|
||||||
public static int LoadFakeIDs(string idType)
|
public static int LoadFakeIDs(string idType)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
|
@ -52,7 +49,12 @@ namespace EnvyUpdate
|
||||||
public static void LogToFile(string content)
|
public static void LogToFile(string content)
|
||||||
{
|
{
|
||||||
if (isVerbose)
|
if (isVerbose)
|
||||||
System.IO.File.AppendAllText(Debug.debugFile, content + "\n");
|
{
|
||||||
|
if (GlobalVars.useAppdata)
|
||||||
|
File.AppendAllText(Path.Combine(GlobalVars.appdata, "envyupdate.log"), content + "\n");
|
||||||
|
else
|
||||||
|
File.AppendAllText(Path.Combine(GlobalVars.directoryOfExe, "envyupdate.log"), content + "\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,14 +6,18 @@ namespace EnvyUpdate
|
||||||
class GlobalVars
|
class GlobalVars
|
||||||
{
|
{
|
||||||
public static bool isMobile = false;
|
public static bool isMobile = false;
|
||||||
public static readonly string exeloc = System.Reflection.Assembly.GetEntryAssembly().Location;
|
public static readonly string pathToAppExe = System.Reflection.Assembly.GetEntryAssembly().Location;
|
||||||
public static readonly string exedirectory = Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location) + "\\";
|
public static readonly string directoryOfExe = Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location);
|
||||||
|
public static string saveDirectory = directoryOfExe;
|
||||||
public static readonly string startmenu = Environment.GetFolderPath(Environment.SpecialFolder.StartMenu);
|
public static readonly string startmenu = Environment.GetFolderPath(Environment.SpecialFolder.StartMenu);
|
||||||
public static readonly string appdata = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\envyupdate\\";
|
public static readonly string legacyAppdata = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\envyupdate\\";
|
||||||
|
public static readonly string appdata = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "EnvyUpdate_Data");
|
||||||
public static readonly string startup = Environment.GetFolderPath(Environment.SpecialFolder.Startup);
|
public static readonly string startup = Environment.GetFolderPath(Environment.SpecialFolder.Startup);
|
||||||
public static bool monitoringInstall = false;
|
public static bool monitoringInstall = false;
|
||||||
public static bool startMinimized = false;
|
public static bool startMinimized = false;
|
||||||
public static bool isInstalling = false;
|
public static bool isInstalling = false;
|
||||||
public static readonly string useragent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:115.0) Gecko/20100101 Firefox/115.0";
|
public static readonly string useragent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:115.0) Gecko/20100101 Firefox/115.0";
|
||||||
|
public static bool useAppdata = false;
|
||||||
|
public static bool hasWrite = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,8 +28,22 @@ namespace EnvyUpdate
|
||||||
// This is necessary, since .NET throws an exception if you check for a non-existant arg.
|
// This is necessary, since .NET throws an exception if you check for a non-existant arg.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!Util.HasWritePermissions())
|
||||||
|
{
|
||||||
|
if (!Directory.Exists(GlobalVars.appdata))
|
||||||
|
Directory.CreateDirectory(GlobalVars.appdata);
|
||||||
|
|
||||||
|
GlobalVars.hasWrite = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Directory.Exists(GlobalVars.appdata))
|
||||||
|
{
|
||||||
|
GlobalVars.useAppdata = true;
|
||||||
|
GlobalVars.saveDirectory = GlobalVars.appdata;
|
||||||
|
}
|
||||||
|
|
||||||
// Check if Debug file exists
|
// Check if Debug file exists
|
||||||
if (File.Exists(Path.Combine(GlobalVars.exedirectory, "envyupdate.log")))
|
if (File.Exists(Path.Combine(GlobalVars.saveDirectory, "envyupdate.log")))
|
||||||
{
|
{
|
||||||
Debug.isVerbose = true;
|
Debug.isVerbose = true;
|
||||||
Debug.LogToFile("------");
|
Debug.LogToFile("------");
|
||||||
|
@ -37,6 +51,7 @@ namespace EnvyUpdate
|
||||||
}
|
}
|
||||||
|
|
||||||
Debug.LogToFile("INFO Starting EnvyUpdate, version " + System.Diagnostics.FileVersionInfo.GetVersionInfo(System.Reflection.Assembly.GetExecutingAssembly().Location).FileVersion);
|
Debug.LogToFile("INFO Starting EnvyUpdate, version " + System.Diagnostics.FileVersionInfo.GetVersionInfo(System.Reflection.Assembly.GetExecutingAssembly().Location).FileVersion);
|
||||||
|
Debug.LogToFile("INFO Save directory: " + GlobalVars.saveDirectory);
|
||||||
|
|
||||||
// Check if running on supported Windows version.
|
// Check if running on supported Windows version.
|
||||||
if (Environment.OSVersion.Version.Major < 10)
|
if (Environment.OSVersion.Version.Major < 10)
|
||||||
|
@ -60,9 +75,9 @@ namespace EnvyUpdate
|
||||||
SystemEvents.UserPreferenceChanged += AdjustTheme;
|
SystemEvents.UserPreferenceChanged += AdjustTheme;
|
||||||
|
|
||||||
// Delete installed legacy versions, required for people upgrading from very old versions.
|
// Delete installed legacy versions, required for people upgrading from very old versions.
|
||||||
if (Directory.Exists(GlobalVars.appdata))
|
if (Directory.Exists(GlobalVars.legacyAppdata))
|
||||||
{
|
{
|
||||||
Debug.LogToFile("INFO Found old appdata installation, uninstalling.");
|
Debug.LogToFile("INFO Found legacy appdata installation, uninstalling.");
|
||||||
Util.UninstallAll();
|
Util.UninstallAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
9
EnvyUpdate/Properties/Resources.Designer.cs
generated
9
EnvyUpdate/Properties/Resources.Designer.cs
generated
|
@ -258,6 +258,15 @@ namespace EnvyUpdate.Properties {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Save files to AppData.
|
||||||
|
/// </summary>
|
||||||
|
public static string ui_enable_appdata {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("ui_enable_appdata", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Enable logging to file.
|
/// Looks up a localized string similar to Enable logging to file.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -183,6 +183,9 @@
|
||||||
<data name="ui_download" xml:space="preserve">
|
<data name="ui_download" xml:space="preserve">
|
||||||
<value>Herunterladen</value>
|
<value>Herunterladen</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="ui_enable_appdata" xml:space="preserve">
|
||||||
|
<value>Programmdaten in AppData speichern</value>
|
||||||
|
</data>
|
||||||
<data name="ui_enable_logging" xml:space="preserve">
|
<data name="ui_enable_logging" xml:space="preserve">
|
||||||
<value>Programm-Log in Datei schreiben</value>
|
<value>Programm-Log in Datei schreiben</value>
|
||||||
</data>
|
</data>
|
||||||
|
|
|
@ -183,6 +183,9 @@
|
||||||
<data name="ui_download" xml:space="preserve">
|
<data name="ui_download" xml:space="preserve">
|
||||||
<value>Download</value>
|
<value>Download</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="ui_enable_appdata" xml:space="preserve">
|
||||||
|
<value>Save files to AppData</value>
|
||||||
|
</data>
|
||||||
<data name="ui_enable_logging" xml:space="preserve">
|
<data name="ui_enable_logging" xml:space="preserve">
|
||||||
<value>Enable logging to file</value>
|
<value>Enable logging to file</value>
|
||||||
</data>
|
</data>
|
||||||
|
|
|
@ -15,7 +15,8 @@
|
||||||
<RowDefinition Height="Auto"/>
|
<RowDefinition Height="Auto"/>
|
||||||
<RowDefinition Height="Auto"/>
|
<RowDefinition Height="Auto"/>
|
||||||
<RowDefinition Height="Auto"/>
|
<RowDefinition Height="Auto"/>
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto"/>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
<RowDefinition />
|
<RowDefinition />
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<Grid Grid.Row="0">
|
<Grid Grid.Row="0">
|
||||||
|
@ -34,8 +35,12 @@
|
||||||
<ui:ToggleSwitch x:Name="chkLog" Checked="chkLog_Checked" Unchecked="chkLog_Unchecked"/>
|
<ui:ToggleSwitch x:Name="chkLog" Checked="chkLog_Checked" Unchecked="chkLog_Unchecked"/>
|
||||||
</ui:CardControl>
|
</ui:CardControl>
|
||||||
|
|
||||||
<Label Grid.Row="3" Content="{x:Static p:Resources.ui_licenses}" HorizontalAlignment="Left" VerticalAlignment="Top" FontWeight="Bold"/>
|
<ui:CardControl Grid.Row="3" Margin="0,12,0,0" Icon="Folder24" Header="{x:Static p:Resources.ui_enable_appdata}" >
|
||||||
<ScrollViewer Grid.Row="4" MaxHeight="700" HorizontalAlignment="Stretch">
|
<ui:ToggleSwitch x:Name="chkAppdata" Checked="chkAppdata_Checked" Unchecked="chkAppdata_Unchecked"/>
|
||||||
|
</ui:CardControl>
|
||||||
|
|
||||||
|
<Label Grid.Row="4" Content="{x:Static p:Resources.ui_licenses}" HorizontalAlignment="Left" VerticalAlignment="Top" FontWeight="Bold"/>
|
||||||
|
<ScrollViewer Grid.Row="5" MaxHeight="700" HorizontalAlignment="Stretch">
|
||||||
<StackPanel>
|
<StackPanel>
|
||||||
<Expander Header="EnvyUpdate">
|
<Expander Header="EnvyUpdate">
|
||||||
<TextBox x:Name="textBoxLicEnvyupdate" IsReadOnly="True" TextWrapping="Wrap"/>
|
<TextBox x:Name="textBoxLicEnvyupdate" IsReadOnly="True" TextWrapping="Wrap"/>
|
||||||
|
|
|
@ -21,9 +21,15 @@ namespace EnvyUpdate
|
||||||
if (GlobalVars.monitoringInstall)
|
if (GlobalVars.monitoringInstall)
|
||||||
textBlockVer.FontStyle = FontStyles.Italic;
|
textBlockVer.FontStyle = FontStyles.Italic;
|
||||||
|
|
||||||
if (File.Exists(Path.Combine(GlobalVars.exedirectory, "envyupdate.log")))
|
if (File.Exists(Path.Combine(GlobalVars.saveDirectory, "envyupdate.log")) || File.Exists(Path.Combine(GlobalVars.appdata, "envyupdate.log")))
|
||||||
chkLog.IsChecked = true;
|
chkLog.IsChecked = true;
|
||||||
|
|
||||||
|
if (GlobalVars.useAppdata)
|
||||||
|
chkAppdata.IsChecked = true;
|
||||||
|
|
||||||
|
if (!GlobalVars.hasWrite)
|
||||||
|
chkAppdata.IsEnabled = false;
|
||||||
|
|
||||||
textBoxLicEnvyupdate.Text = Properties.Licenses.EnvyUpdate;
|
textBoxLicEnvyupdate.Text = Properties.Licenses.EnvyUpdate;
|
||||||
textBoxLicFody.Text = Properties.Licenses.Fody;
|
textBoxLicFody.Text = Properties.Licenses.Fody;
|
||||||
textBoxLicCostura.Text = Properties.Licenses.CosturaFody;
|
textBoxLicCostura.Text = Properties.Licenses.CosturaFody;
|
||||||
|
@ -54,10 +60,36 @@ namespace EnvyUpdate
|
||||||
if (Debug.isVerbose)
|
if (Debug.isVerbose)
|
||||||
{
|
{
|
||||||
Debug.LogToFile("INFO Disabled logging to file.");
|
Debug.LogToFile("INFO Disabled logging to file.");
|
||||||
if (File.Exists(Path.Combine(GlobalVars.exedirectory, "envyupdate.log")))
|
if (File.Exists(Path.Combine(GlobalVars.saveDirectory, "envyupdate.log")))
|
||||||
File.Move(Path.Combine(GlobalVars.exedirectory, "envyupdate.log"), Path.Combine(GlobalVars.exedirectory, "envyupdate." + DateTime.Now.ToString("yyyyMMdd-HHmmss") + ".log"));
|
File.Move(Path.Combine(GlobalVars.saveDirectory, "envyupdate.log"), Path.Combine(GlobalVars.saveDirectory, "envyupdate." + DateTime.Now.ToString("yyyyMMdd-HHmmss") + ".log"));
|
||||||
Debug.isVerbose = false;
|
Debug.isVerbose = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void chkAppdata_Checked(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
if (!Directory.Exists(GlobalVars.appdata))
|
||||||
|
Directory.CreateDirectory(GlobalVars.appdata);
|
||||||
|
|
||||||
|
GlobalVars.useAppdata = true;
|
||||||
|
GlobalVars.saveDirectory = GlobalVars.appdata;
|
||||||
|
Util.MoveFilesToAppdata();
|
||||||
|
|
||||||
|
Debug.LogToFile("INFO Switched to AppData directory.");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void chkAppdata_Unchecked(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
GlobalVars.useAppdata = false;
|
||||||
|
GlobalVars.saveDirectory = GlobalVars.directoryOfExe;
|
||||||
|
|
||||||
|
if (Directory.Exists(GlobalVars.appdata))
|
||||||
|
{
|
||||||
|
Util.MoveFilesToExe();
|
||||||
|
Directory.Delete(GlobalVars.appdata, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
Debug.LogToFile("INFO Switched to EXE directory.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using IWshRuntimeLibrary;
|
using IWshRuntimeLibrary;
|
||||||
|
using Microsoft.Build.Framework.XamlTypes;
|
||||||
using Microsoft.Win32;
|
using Microsoft.Win32;
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
@ -130,13 +131,11 @@ namespace EnvyUpdate
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void SelfDelete()
|
public static void SelfDelete()
|
||||||
{
|
{
|
||||||
string appdata = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\envyupdate\\";
|
|
||||||
|
|
||||||
Process process = new Process();
|
Process process = new Process();
|
||||||
ProcessStartInfo startInfo = new ProcessStartInfo
|
ProcessStartInfo startInfo = new ProcessStartInfo
|
||||||
{
|
{
|
||||||
WindowStyle = ProcessWindowStyle.Hidden,
|
WindowStyle = ProcessWindowStyle.Hidden,
|
||||||
WorkingDirectory = appdata,
|
WorkingDirectory = GlobalVars.legacyAppdata,
|
||||||
FileName = "cmd.exe",
|
FileName = "cmd.exe",
|
||||||
Arguments = "/C timeout 5 && del EnvyUpdate.exe"
|
Arguments = "/C timeout 5 && del EnvyUpdate.exe"
|
||||||
};
|
};
|
||||||
|
@ -433,7 +432,7 @@ namespace EnvyUpdate
|
||||||
*/
|
*/
|
||||||
//TODO: find way to differentiate between driver types
|
//TODO: find way to differentiate between driver types
|
||||||
|
|
||||||
if (System.IO.File.Exists(GlobalVars.exedirectory + "sd.envy"))
|
if (System.IO.File.Exists(Path.Combine(GlobalVars.saveDirectory, "sd.envy")))
|
||||||
return 18;
|
return 18;
|
||||||
else
|
else
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -510,27 +509,27 @@ namespace EnvyUpdate
|
||||||
|
|
||||||
public static void UninstallAll()
|
public static void UninstallAll()
|
||||||
{
|
{
|
||||||
if (System.IO.File.Exists(GlobalVars.startup + "\\EnvyUpdate.lnk"))
|
if (System.IO.File.Exists(Path.Combine(GlobalVars.startup, "\\EnvyUpdate.lnk")))
|
||||||
{
|
{
|
||||||
Debug.LogToFile("INFO Deleted startup entry.");
|
Debug.LogToFile("INFO Deleted startup entry.");
|
||||||
System.IO.File.Delete(GlobalVars.startup + "\\EnvyUpdate.lnk");
|
System.IO.File.Delete(Path.Combine(GlobalVars.startup, "\\EnvyUpdate.lnk"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (System.IO.File.Exists(GlobalVars.startmenu + "\\EnvyUpdate.lnk"))
|
if (System.IO.File.Exists(Path.Combine(GlobalVars.startmenu, "\\EnvyUpdate.lnk")))
|
||||||
{
|
{
|
||||||
Debug.LogToFile("INFO Deleted start menu entry.");
|
Debug.LogToFile("INFO Deleted start menu entry.");
|
||||||
System.IO.File.Delete(GlobalVars.startmenu + "\\EnvyUpdate.lnk");
|
System.IO.File.Delete(Path.Combine(GlobalVars.startmenu, "\\EnvyUpdate.lnk"));
|
||||||
}
|
}
|
||||||
if ((GlobalVars.exedirectory == GlobalVars.appdata) && System.IO.File.Exists(GlobalVars.appdata + "EnvyUpdate.exe"))
|
if ((GlobalVars.saveDirectory == GlobalVars.legacyAppdata) && System.IO.File.Exists(Path.Combine(GlobalVars.legacyAppdata, "EnvyUpdate.exe")))
|
||||||
{
|
{
|
||||||
Debug.LogToFile("INFO Deleting EnvyUpdate appdata and self.");
|
Debug.LogToFile("INFO Deleting EnvyUpdate appdata and self.");
|
||||||
MessageBox.Show(Properties.Resources.uninstall_legacy_message);
|
MessageBox.Show(Properties.Resources.uninstall_legacy_message);
|
||||||
Util.SelfDelete();
|
Util.SelfDelete();
|
||||||
}
|
}
|
||||||
else if (Directory.Exists(GlobalVars.appdata))
|
else if (Directory.Exists(GlobalVars.legacyAppdata))
|
||||||
{
|
{
|
||||||
Debug.LogToFile("INFO Deleting EnvyUpdate appdata folder");
|
Debug.LogToFile("INFO Deleting EnvyUpdate appdata folder");
|
||||||
Directory.Delete(GlobalVars.appdata, true);
|
Directory.Delete(GlobalVars.legacyAppdata, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -579,7 +578,7 @@ namespace EnvyUpdate
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
path = Path.Combine(GlobalVars.exedirectory, "7zr.exe");
|
path = Path.Combine(GlobalVars.saveDirectory, "7zr.exe");
|
||||||
using (WebClient client = new WebClient())
|
using (WebClient client = new WebClient())
|
||||||
{
|
{
|
||||||
client.Headers["User-Agent"] = GlobalVars.useragent;
|
client.Headers["User-Agent"] = GlobalVars.useragent;
|
||||||
|
@ -664,5 +663,37 @@ namespace EnvyUpdate
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static bool HasWritePermissions()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
System.IO.File.Create(Path.Combine(GlobalVars.saveDirectory, "writeable.envy")).Close();
|
||||||
|
System.IO.File.Delete(Path.Combine(GlobalVars.saveDirectory, "writeable.envy"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void MoveFilesToAppdata()
|
||||||
|
{
|
||||||
|
string[] envyFiles = Directory.GetFiles(GlobalVars.directoryOfExe, "*.envy");
|
||||||
|
foreach (var item in envyFiles)
|
||||||
|
System.IO.File.Move(item, Path.Combine(GlobalVars.appdata, Path.GetFileName(item)));
|
||||||
|
if (System.IO.File.Exists(Path.Combine(GlobalVars.directoryOfExe, "envyupdate.log")))
|
||||||
|
System.IO.File.Move(Path.Combine(GlobalVars.directoryOfExe, "envyupdate.log"), Path.Combine(GlobalVars.appdata, "envyupdate.log"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void MoveFilesToExe()
|
||||||
|
{
|
||||||
|
string[] envyFiles = Directory.GetFiles(GlobalVars.appdata, "*.envy");
|
||||||
|
foreach (var item in envyFiles)
|
||||||
|
System.IO.File.Move(item, Path.Combine(GlobalVars.directoryOfExe, Path.GetFileName(item)));
|
||||||
|
if (System.IO.File.Exists(Path.Combine(GlobalVars.appdata, "envyupdate.log")))
|
||||||
|
System.IO.File.Move(Path.Combine(GlobalVars.appdata, "envyupdate.log"), Path.Combine(GlobalVars.directoryOfExe, "envyupdate.log"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue