[BUG] Fix FileNotFoundException - Option GenerateDriveShortcuts - in case Windows Defender triggered (#272), version 1.2.0.3

This commit is contained in:
Markus Hofknecht 2021-12-27 06:28:29 +01:00
parent 6d3832521f
commit 401e1329f1

View file

@ -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)