diff --git a/Wox.Core/Configuration/Portable.cs b/Wox.Core/Configuration/Portable.cs index 422bbc2f8..5cb746f54 100644 --- a/Wox.Core/Configuration/Portable.cs +++ b/Wox.Core/Configuration/Portable.cs @@ -1,3 +1,4 @@ +using Microsoft.Win32; using Squirrel; using System; using Wox.Infrastructure; @@ -16,12 +17,13 @@ namespace Wox.Core.Configuration public Portable() { + //NEED TO DYNAMICALLY GET WOX'S LOCATION OTHERWISE SHORTCUTS WONT WORK applicationName = Constant.Wox; exeName = applicationName + ".exe"; rootAppDirectory = Constant.RootDirectory; - portabilityUpdater = new UpdateManager(string.Empty, applicationName, rootAppDirectory); + portabilityUpdater = new UpdateManager(string.Empty, applicationName, rootAppDirectory); - roamingDataPath = Constant.RoamingDataPath; + roamingDataPath = Constant.RoamingDataPath; portableDataPath = Constant.PortableDataPath; } @@ -31,7 +33,7 @@ namespace Wox.Core.Configuration { MoveUserDataFolder(portableDataPath, roamingDataPath); CreateShortcuts(); - CreateUninstallerEntry(); + CreateUninstallerEntry(); //DOES NOT CREATE THE UNINSTALLER ICON!!!!!! // always dispose UpdateManager??????????? // CHANGE TO PRIVATE/INTERNAL METHODS @@ -108,7 +110,17 @@ namespace Wox.Core.Configuration public void CreateUninstallerEntry() { - portabilityUpdater.CreateUninstallerRegistryEntry(); + var uninstallRegSubKey = @"Software\Microsoft\Windows\CurrentVersion\Uninstall"; + // NB: Sometimes the Uninstall key doesn't exist + using (var parentKey = + RegistryKey.OpenBaseKey(RegistryHive.CurrentUser, RegistryView.Default) + .CreateSubKey("Uninstall", RegistryKeyPermissionCheck.ReadWriteSubTree)) {; } + + var key = RegistryKey.OpenBaseKey(RegistryHive.CurrentUser, RegistryView.Default) + .CreateSubKey(uninstallRegSubKey + "\\" + applicationName, RegistryKeyPermissionCheck.ReadWriteSubTree); + key.SetValue("DisplayIcon", Constant.ApplicationDirectory + "\\app.ico", RegistryValueKind.String); + + portabilityUpdater.CreateUninstallerRegistryEntry().Wait(); } } } diff --git a/Wox.Infrastructure/Wox.cs b/Wox.Infrastructure/Wox.cs index 8507ee393..35faa102c 100644 --- a/Wox.Infrastructure/Wox.cs +++ b/Wox.Infrastructure/Wox.cs @@ -13,7 +13,7 @@ namespace Wox.Infrastructure private static readonly Assembly Assembly = Assembly.GetExecutingAssembly(); public static readonly string ProgramDirectory = Directory.GetParent(Assembly.Location.NonNull()).ToString(); public static readonly string ExecutablePath = Path.Combine(ProgramDirectory, Wox + ".exe"); - private static readonly string ApplicationDirectory = Directory.GetParent(ProgramDirectory).ToString(); + public static readonly string ApplicationDirectory = Directory.GetParent(ProgramDirectory).ToString(); public static readonly string RootDirectory = Directory.GetParent(ApplicationDirectory).ToString(); public const string PortableFolderName = "UserData"; diff --git a/Wox/ViewModel/SettingWindowViewModel.cs b/Wox/ViewModel/SettingWindowViewModel.cs index b827130b1..d26f86cb9 100644 --- a/Wox/ViewModel/SettingWindowViewModel.cs +++ b/Wox/ViewModel/SettingWindowViewModel.cs @@ -55,6 +55,11 @@ namespace Wox.ViewModel _portable.EnablePortableMode(); } + public void DisablePortableMode() + { + _portable.DisablePortableMode(); + } + public void Save() { _storage.Save();