Skip to content

Commit 8a2d474

Browse files
authored
[PTRun]Fix locking link files for MSI installers. Warning 1946 (#37654)
* [Runner] fix MSI installer issue. Warning 1946 * Fix catching exceptions * Better error handling * Revert "Better error handling" This reverts commit 0f3ec2a.
1 parent bf26857 commit 8a2d474

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/modules/launcher/Wox.Infrastructure/ShellLinkHelper.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,25 @@ public string RetrieveTargetPath(string path)
136136
var link = new ShellLink();
137137
const int STGM_READ = 0;
138138

139+
// Make sure not to open exclusive handles.
140+
// See: https://github.com/microsoft/WSL/issues/11276
141+
const int STGM_SHARE_DENY_NONE = 0x00000040;
142+
const int STGM_TRANSACTED = 0x00010000;
143+
139144
try
140145
{
141-
((IPersistFile)link).Load(path, STGM_READ);
146+
((IPersistFile)link).Load(path, STGM_READ | STGM_SHARE_DENY_NONE | STGM_TRANSACTED);
142147
}
143148
catch (System.IO.FileNotFoundException ex)
144149
{
145-
Log.Exception("Path could not be retrieved", ex, GetType(), path);
150+
Log.Exception("Path could not be retrieved " + path, ex, GetType(), path);
151+
Marshal.ReleaseComObject(link);
152+
return string.Empty;
153+
}
154+
catch (System.Exception ex)
155+
{
156+
Log.Exception("Exception loading path " + path, ex, GetType(), path);
157+
Marshal.ReleaseComObject(link);
146158
return string.Empty;
147159
}
148160

0 commit comments

Comments
 (0)