diff --git a/Plugins/Wox.Plugin.Program/ProgramSources/AppPathsProgramSource.cs b/Plugins/Wox.Plugin.Program/ProgramSources/AppPathsProgramSource.cs index 5b50d72df1..16e0961b3d 100644 --- a/Plugins/Wox.Plugin.Program/ProgramSources/AppPathsProgramSource.cs +++ b/Plugins/Wox.Plugin.Program/ProgramSources/AppPathsProgramSource.cs @@ -1,21 +1,21 @@ using System; using System.Collections.Generic; +using Wox.Infrastructure.Logger; namespace Wox.Plugin.Program.ProgramSources { [Serializable] - [global::System.ComponentModel.Browsable(false)] - public class AppPathsProgramSource: AbstractProgramSource + [System.ComponentModel.Browsable(false)] + public class AppPathsProgramSource : AbstractProgramSource { public AppPathsProgramSource() { - this.BonusPoints = -10; + BonusPoints = -10; } - public AppPathsProgramSource(ProgramSource source) - : this() + public AppPathsProgramSource(ProgramSource source) : this() { - this.BonusPoints = source.BonusPoints; + BonusPoints = source.BonusPoints; } public override List LoadPrograms() @@ -33,17 +33,31 @@ namespace Wox.Plugin.Program.ProgramSources if (root == null) return; foreach (var item in root.GetSubKeyNames()) { - using (var key = root.OpenSubKey(item)) + try { - object path = key.GetValue(""); - if (path is string && global::System.IO.File.Exists((string)path)) + using (var key = root.OpenSubKey(item)) { - var entry = CreateEntry((string)path); + string path = key.GetValue("") as string; + if (path == null) continue; + + // fix path like this ""\"C:\\folder\\executable.exe\""" + const int begin = 0; + int end = path.Length - 1; + const char quotationMark = '"'; + if (path[begin] == quotationMark && path[end] == quotationMark) + { + path = path.Substring(begin + 1, path.Length - 2); + } + + if (!System.IO.File.Exists(path)) continue; + var entry = CreateEntry(path); entry.ExecuteName = item; list.Add(entry); } - - key.Close(); + } + catch (Exception e) + { + Log.Error(e.StackTrace); } } }