mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 11:48:06 +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">
|
<Custom Action="UnRegisterContextMenuPackages" Before="RemoveFiles">
|
||||||
Installed AND (REMOVE="ALL")
|
Installed AND (REMOVE="ALL")
|
||||||
</Custom>
|
</Custom>
|
||||||
|
<Custom Action="UnRegisterCmdPalPackage" Before="RemoveFiles">
|
||||||
|
Installed AND (NOT UPGRADINGPRODUCTCODE) AND (REMOVE="ALL")
|
||||||
|
</Custom>
|
||||||
<Custom Action="UnsetAdvancedPasteAPIKey" Before="RemoveFiles">
|
<Custom Action="UnsetAdvancedPasteAPIKey" Before="RemoveFiles">
|
||||||
Installed AND (NOT UPGRADINGPRODUCTCODE) AND (REMOVE="ALL")
|
Installed AND (NOT UPGRADINGPRODUCTCODE) AND (REMOVE="ALL")
|
||||||
</Custom>
|
</Custom>
|
||||||
@@ -439,6 +442,14 @@
|
|||||||
DllEntry="UnRegisterContextMenuPackagesCA"
|
DllEntry="UnRegisterContextMenuPackagesCA"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<CustomAction Id="UnRegisterCmdPalPackage"
|
||||||
|
Return="ignore"
|
||||||
|
Impersonate="yes"
|
||||||
|
Execute="deferred"
|
||||||
|
BinaryKey="PTCustomActions"
|
||||||
|
DllEntry="UnRegisterCmdPalPackageCA"
|
||||||
|
/>
|
||||||
|
|
||||||
<CustomAction Id="CheckGPO"
|
<CustomAction Id="CheckGPO"
|
||||||
Return="check"
|
Return="check"
|
||||||
Impersonate="yes"
|
Impersonate="yes"
|
||||||
|
|||||||
@@ -1081,6 +1081,41 @@ UINT __stdcall InstallCmdPalPackageCA(MSIHANDLE hInstall)
|
|||||||
return WcaFinalize(er);
|
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)
|
UINT __stdcall UnRegisterContextMenuPackagesCA(MSIHANDLE hInstall)
|
||||||
{
|
{
|
||||||
using namespace winrt::Windows::Foundation;
|
using namespace winrt::Windows::Foundation;
|
||||||
@@ -1094,7 +1129,7 @@ UINT __stdcall UnRegisterContextMenuPackagesCA(MSIHANDLE hInstall)
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Packages to unregister
|
// 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)
|
for (auto const &package : packagesToRemoveDisplayName)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ EXPORTS
|
|||||||
InstallDSCModuleCA
|
InstallDSCModuleCA
|
||||||
InstallCmdPalPackageCA
|
InstallCmdPalPackageCA
|
||||||
UnApplyModulesRegistryChangeSetsCA
|
UnApplyModulesRegistryChangeSetsCA
|
||||||
|
UnRegisterCmdPalPackageCA
|
||||||
UnRegisterContextMenuPackagesCA
|
UnRegisterContextMenuPackagesCA
|
||||||
UninstallEmbeddedMSIXCA
|
UninstallEmbeddedMSIXCA
|
||||||
UninstallDSCModuleCA
|
UninstallDSCModuleCA
|
||||||
|
|||||||
Reference in New Issue
Block a user