mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-15 03:07:56 +01:00
[Installer]Properly update CmdPal on upgrade (#38070)
* [Installer]Properly update CmdPal on upgrade * Update installer/PowerToysSetupCustomActions/CustomAction.cpp
This commit is contained in:
@@ -179,6 +179,9 @@
|
||||
<Custom Action="UnRegisterContextMenuPackages" Before="RemoveFiles">
|
||||
Installed AND (REMOVE="ALL")
|
||||
</Custom>
|
||||
<Custom Action="UnRegisterCmdPalPackage" Before="RemoveFiles">
|
||||
Installed AND (NOT UPGRADINGPRODUCTCODE) AND (REMOVE="ALL")
|
||||
</Custom>
|
||||
<Custom Action="UnsetAdvancedPasteAPIKey" Before="RemoveFiles">
|
||||
Installed AND (NOT UPGRADINGPRODUCTCODE) AND (REMOVE="ALL")
|
||||
</Custom>
|
||||
@@ -439,6 +442,14 @@
|
||||
DllEntry="UnRegisterContextMenuPackagesCA"
|
||||
/>
|
||||
|
||||
<CustomAction Id="UnRegisterCmdPalPackage"
|
||||
Return="ignore"
|
||||
Impersonate="yes"
|
||||
Execute="deferred"
|
||||
BinaryKey="PTCustomActions"
|
||||
DllEntry="UnRegisterCmdPalPackageCA"
|
||||
/>
|
||||
|
||||
<CustomAction Id="CheckGPO"
|
||||
Return="check"
|
||||
Impersonate="yes"
|
||||
|
||||
@@ -1081,6 +1081,41 @@ UINT __stdcall InstallCmdPalPackageCA(MSIHANDLE hInstall)
|
||||
return WcaFinalize(er);
|
||||
}
|
||||
|
||||
UINT __stdcall UnRegisterCmdPalPackageCA(MSIHANDLE hInstall)
|
||||
{
|
||||
using namespace winrt::Windows::Foundation;
|
||||
using namespace winrt::Windows::Management::Deployment;
|
||||
|
||||
HRESULT hr = S_OK;
|
||||
UINT er = ERROR_SUCCESS;
|
||||
|
||||
hr = WcaInitialize(hInstall, "UnRegisterCmdPalPackageCA");
|
||||
|
||||
try
|
||||
{
|
||||
// Packages to unregister
|
||||
std::wstring packageToRemoveDisplayName {L"Microsoft.CommandPalette"};
|
||||
|
||||
if (!package::UnRegisterPackage(packageToRemoveDisplayName))
|
||||
{
|
||||
Logger::error(L"Failed to unregister package: " + packageToRemoveDisplayName);
|
||||
er = ERROR_INSTALL_FAILURE;
|
||||
}
|
||||
}
|
||||
catch (std::exception &e)
|
||||
{
|
||||
std::string errorMessage{"Exception thrown while trying to unregister the CmdPal package: "};
|
||||
errorMessage += e.what();
|
||||
Logger::error(errorMessage);
|
||||
|
||||
er = ERROR_INSTALL_FAILURE;
|
||||
}
|
||||
|
||||
er = er == ERROR_SUCCESS ? (SUCCEEDED(hr) ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE) : er;
|
||||
return WcaFinalize(er);
|
||||
}
|
||||
|
||||
|
||||
UINT __stdcall UnRegisterContextMenuPackagesCA(MSIHANDLE hInstall)
|
||||
{
|
||||
using namespace winrt::Windows::Foundation;
|
||||
@@ -1094,7 +1129,7 @@ UINT __stdcall UnRegisterContextMenuPackagesCA(MSIHANDLE hInstall)
|
||||
try
|
||||
{
|
||||
// Packages to unregister
|
||||
const std::vector<std::wstring> packagesToRemoveDisplayName{{L"PowerRenameContextMenu"}, {L"ImageResizerContextMenu"}, {L"FileLocksmithContextMenu"}, {L"NewPlusContextMenu"}, {L"Microsoft.CommandPalette"}};
|
||||
const std::vector<std::wstring> packagesToRemoveDisplayName{{L"PowerRenameContextMenu"}, {L"ImageResizerContextMenu"}, {L"FileLocksmithContextMenu"}, {L"NewPlusContextMenu"}};
|
||||
|
||||
for (auto const &package : packagesToRemoveDisplayName)
|
||||
{
|
||||
|
||||
@@ -20,6 +20,7 @@ EXPORTS
|
||||
InstallDSCModuleCA
|
||||
InstallCmdPalPackageCA
|
||||
UnApplyModulesRegistryChangeSetsCA
|
||||
UnRegisterCmdPalPackageCA
|
||||
UnRegisterContextMenuPackagesCA
|
||||
UninstallEmbeddedMSIXCA
|
||||
UninstallDSCModuleCA
|
||||
|
||||
Reference in New Issue
Block a user