From 0b67fd0858a74ee9fcd9d693d9750d29c65cbbaa Mon Sep 17 00:00:00 2001 From: Alex Modin Date: Thu, 31 Oct 2019 00:20:22 +0400 Subject: [PATCH 1/2] Wrapped filesystem actions within try/catch to avoid unexpected launch crashes --- DS4Windows/DS4Forms/DS4Form.cs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/DS4Windows/DS4Forms/DS4Form.cs b/DS4Windows/DS4Forms/DS4Form.cs index 76af3bc..6c884f0 100644 --- a/DS4Windows/DS4Forms/DS4Form.cs +++ b/DS4Windows/DS4Forms/DS4Form.cs @@ -346,9 +346,18 @@ namespace DS4Windows.Forms if (onlylnkpath != Process.GetCurrentProcess().MainModule.FileName) { - File.Delete(Environment.GetFolderPath(Environment.SpecialFolder.Startup) + "\\DS4Windows.lnk"); - appShortcutToStartup(); - changeStartupRoutine(); + try + { + File.Delete(Environment.GetFolderPath(Environment.SpecialFolder.Startup) + "\\DS4Windows.lnk"); + appShortcutToStartup(); + changeStartupRoutine(); + } + catch + { + MessageBox.Show("No access to Autorun/DS4Windows.lnk\nPlease check file permissions", "DS4Windows"); + StartWindowsCheckBox.Checked = false; + runStartupPanel.Visible = false; + } } } From 9d2ded06065d044009343588aeda4ec6b3954328 Mon Sep 17 00:00:00 2001 From: Travis Nickles Date: Mon, 4 Nov 2019 01:08:05 -0600 Subject: [PATCH 2/2] Modify for read only lnk check. Should be sufficient --- DS4Windows/DS4Forms/DS4Form.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/DS4Windows/DS4Forms/DS4Form.cs b/DS4Windows/DS4Forms/DS4Form.cs index 6c884f0..aa7b9a5 100644 --- a/DS4Windows/DS4Forms/DS4Form.cs +++ b/DS4Windows/DS4Forms/DS4Form.cs @@ -346,15 +346,15 @@ namespace DS4Windows.Forms if (onlylnkpath != Process.GetCurrentProcess().MainModule.FileName) { - try + string ds4lnkpath = Environment.GetFolderPath(Environment.SpecialFolder.Startup) + "\\DS4Windows.lnk"; + if (!new FileInfo(ds4lnkpath).IsReadOnly) { - File.Delete(Environment.GetFolderPath(Environment.SpecialFolder.Startup) + "\\DS4Windows.lnk"); + File.Delete(ds4lnkpath); appShortcutToStartup(); changeStartupRoutine(); } - catch + else { - MessageBox.Show("No access to Autorun/DS4Windows.lnk\nPlease check file permissions", "DS4Windows"); StartWindowsCheckBox.Checked = false; runStartupPanel.Visible = false; }