From 39073f0467ae72b7b8549859f5a0174e896beb84 Mon Sep 17 00:00:00 2001 From: moooyo <42196638+moooyo@users.noreply.github.com> Date: Fri, 14 Mar 2025 10:33:15 +0800 Subject: [PATCH] Fix the problem which Powertoys Run shows duplicated applications. (#37924) init Co-authored-by: Yu Leng (from Dev Box) --- .../Storage/Win32ProgramRepository.cs | 6 ++++++ src/modules/launcher/Wox.Infrastructure/ShellLinkHelper.cs | 7 +------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Storage/Win32ProgramRepository.cs b/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Storage/Win32ProgramRepository.cs index 7277f9aec7..d0cb0a9390 100644 --- a/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Storage/Win32ProgramRepository.cs +++ b/src/modules/launcher/Plugins/Microsoft.Plugin.Program/Storage/Win32ProgramRepository.cs @@ -96,6 +96,12 @@ namespace Microsoft.Plugin.Program.Storage string oldPath = e.OldFullPath; string newPath = e.FullPath; + // fix for https://github.com/microsoft/PowerToys/issues/34391 + // the msi installer creates a shortcut, which is detected by the PT Run and ends up in calling this OnAppRenamed method + // the thread needs to be halted for a short time to avoid locking the new shortcut file as we read it, otherwise the lock causes + // in the issue scenario that a warning is popping up during the msi install process. + System.Threading.Thread.Sleep(1000); + string extension = Path.GetExtension(newPath); Win32Program.ApplicationType oldAppType = Win32Program.GetAppTypeFromPath(oldPath); Programs.Win32Program newApp = Win32Program.GetAppFromPath(newPath); diff --git a/src/modules/launcher/Wox.Infrastructure/ShellLinkHelper.cs b/src/modules/launcher/Wox.Infrastructure/ShellLinkHelper.cs index b18a0f1e3c..1eddf77f33 100644 --- a/src/modules/launcher/Wox.Infrastructure/ShellLinkHelper.cs +++ b/src/modules/launcher/Wox.Infrastructure/ShellLinkHelper.cs @@ -136,14 +136,9 @@ namespace Wox.Infrastructure var link = new ShellLink(); const int STGM_READ = 0; - // Make sure not to open exclusive handles. - // See: https://github.com/microsoft/WSL/issues/11276 - const int STGM_SHARE_DENY_NONE = 0x00000040; - const int STGM_TRANSACTED = 0x00010000; - try { - ((IPersistFile)link).Load(path, STGM_READ | STGM_SHARE_DENY_NONE | STGM_TRANSACTED); + ((IPersistFile)link).Load(path, STGM_READ); } catch (System.IO.FileNotFoundException ex) {