@@ -25,8 +25,19 @@ public class Win32 : IProgram, IEquatable<Win32>
25
25
public string Name { get ; set ; }
26
26
public string UniqueIdentifier { get => _uid ; set => _uid = value == null ? string . Empty : value . ToLowerInvariant ( ) ; } // For path comparison
27
27
public string IcoPath { get ; set ; }
28
+ /// <summary>
29
+ /// Path of the file. It's the path of .lnk or .url for .lnk and .url.
30
+ /// </summary>
28
31
public string FullPath { get ; set ; }
32
+ /// <summary>
33
+ /// Path of the excutable for .lnk, or the URL for .url.
34
+ /// </summary>
29
35
public string LnkResolvedPath { get ; set ; }
36
+ /// <summary>
37
+ /// Path of the actual executable file.
38
+ /// </summary>
39
+ public string ExecutablePath => LnkResolvedPath ?? FullPath ;
40
+ public string WorkingDir => Directory . GetParent ( ExecutablePath ) ? . FullName ?? string . Empty ;
30
41
public string ParentDirectory { get ; set ; }
31
42
public string ExecutableName { get ; set ; }
32
43
public string Description { get ; set ; }
@@ -97,10 +108,23 @@ public Result Result(string query, IPublicAPI api)
97
108
matchResult . MatchData = new List < int > ( ) ;
98
109
}
99
110
111
+ string subtitle = string . Empty ;
112
+ if ( ! Main . _settings . HideAppsPath )
113
+ {
114
+ if ( Extension ( FullPath ) == UrlExtension )
115
+ {
116
+ subtitle = LnkResolvedPath ;
117
+ }
118
+ else
119
+ {
120
+ subtitle = FullPath ;
121
+ }
122
+ }
123
+
100
124
var result = new Result
101
125
{
102
126
Title = title ,
103
- SubTitle = Main . _settings . HideAppsPath ? string . Empty : LnkResolvedPath ?? FullPath ,
127
+ SubTitle = subtitle ,
104
128
IcoPath = IcoPath ,
105
129
Score = matchResult . Score ,
106
130
TitleHighlightData = matchResult . MatchData ,
@@ -116,8 +140,8 @@ public Result Result(string query, IPublicAPI api)
116
140
117
141
var info = new ProcessStartInfo
118
142
{
119
- FileName = LnkResolvedPath ?? FullPath ,
120
- WorkingDirectory = ParentDirectory ,
143
+ FileName = ExecutablePath ,
144
+ WorkingDirectory = WorkingDir ,
121
145
UseShellExecute = true ,
122
146
Verb = runAsAdmin ? "runas" : null
123
147
} ;
@@ -143,8 +167,8 @@ public List<Result> ContextMenus(IPublicAPI api)
143
167
{
144
168
var info = new ProcessStartInfo
145
169
{
146
- FileName = FullPath ,
147
- WorkingDirectory = ParentDirectory ,
170
+ FileName = ExecutablePath ,
171
+ WorkingDirectory = WorkingDir ,
148
172
UseShellExecute = true
149
173
} ;
150
174
@@ -162,8 +186,8 @@ public List<Result> ContextMenus(IPublicAPI api)
162
186
{
163
187
var info = new ProcessStartInfo
164
188
{
165
- FileName = FullPath ,
166
- WorkingDirectory = ParentDirectory ,
189
+ FileName = ExecutablePath ,
190
+ WorkingDirectory = WorkingDir ,
167
191
Verb = "runas" ,
168
192
UseShellExecute = true
169
193
} ;
@@ -250,8 +274,7 @@ private static Win32 LnkProgram(string path)
250
274
var extension = Extension ( target ) ;
251
275
if ( extension == ExeExtension && File . Exists ( target ) )
252
276
{
253
- program . LnkResolvedPath = program . FullPath ;
254
- program . FullPath = Path . GetFullPath ( target ) . ToLowerInvariant ( ) ;
277
+ program . LnkResolvedPath = Path . GetFullPath ( target ) ;
255
278
program . ExecutableName = Path . GetFileName ( target ) ;
256
279
257
280
var description = _helper . description ;
@@ -550,7 +573,7 @@ public static IEnumerable<T> DistinctBy<T, R>(IEnumerable<T> source, Func<T, R>
550
573
551
574
private static IEnumerable < Win32 > ProgramsHasher ( IEnumerable < Win32 > programs )
552
575
{
553
- return programs . GroupBy ( p => p . FullPath . ToLowerInvariant ( ) )
576
+ return programs . GroupBy ( p => p . ExecutablePath . ToLowerInvariant ( ) )
554
577
. AsParallel ( )
555
578
. SelectMany ( g =>
556
579
{
0 commit comments