From 401e1329f1fa1e1672615b732f42c0f07f45a762 Mon Sep 17 00:00:00 2001 From: Markus Hofknecht Date: Mon, 27 Dec 2021 06:28:29 +0100 Subject: [PATCH] [BUG] Fix FileNotFoundException - Option GenerateDriveShortcuts - in case Windows Defender triggered (#272), version 1.2.0.3 --- Utilities/GenerateDriveShortcuts.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Utilities/GenerateDriveShortcuts.cs b/Utilities/GenerateDriveShortcuts.cs index 39c46b8..d18a1bc 100644 --- a/Utilities/GenerateDriveShortcuts.cs +++ b/Utilities/GenerateDriveShortcuts.cs @@ -4,6 +4,7 @@ namespace SystemTrayMenu.Utilities { + using System; using System.Collections.Generic; using System.IO; using System.Linq; @@ -39,7 +40,15 @@ namespace SystemTrayMenu.Utilities IWshShortcut shortcut = (IWshShortcut)shell.CreateShortcut(linkPath); shortcut.Description = "Generated by SystemTrayMenu"; shortcut.TargetPath = targetPath; - shortcut.Save(); + + try + { + shortcut.Save(); + } + catch (Exception ex) + { + Log.Warn($"Could not create shortcut at path:'{linkPath}'", ex); + } } private static string GetLinkPathFromDriveName(string driveName)