mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-02-23 19:49:43 +01:00
* [Updating] Create a dedicated executable project for updating procedures * [Updating] Use PowerToys.Update for update procedures (#11495) * [Updating] Use PowerToys.Update for update procedures * [Setup] Remove toast notifications and other dependencies from bootstrapper * [Installer] Remove Winstore, redundant strings * [Settings] Remove deprecated 'packaged' setting
46 lines
1.5 KiB
C++
46 lines
1.5 KiB
C++
#include "pch.h"
|
|
|
|
#include "installer.h"
|
|
#include <common/version/version.h>
|
|
#include <common/utils/MsiUtils.h>
|
|
#include <common/utils/os-detect.h>
|
|
#include "utils/winapi_error.h"
|
|
|
|
namespace // Strings in this namespace should not be localized
|
|
{
|
|
const wchar_t DONT_SHOW_AGAIN_RECORD_REGISTRY_PATH[] = L"delete_previous_powertoys_confirm";
|
|
|
|
const wchar_t TOAST_TITLE[] = L"PowerToys";
|
|
|
|
const wchar_t MSIX_PACKAGE_NAME[] = L"Microsoft.PowerToys";
|
|
const wchar_t MSIX_PACKAGE_PUBLISHER[] = L"CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US";
|
|
}
|
|
|
|
namespace updating
|
|
{
|
|
std::future<bool> uninstall_previous_msix_version_async()
|
|
{
|
|
winrt::Windows::Management::Deployment::PackageManager package_manager;
|
|
|
|
try
|
|
{
|
|
auto packages = package_manager.FindPackagesForUser({}, MSIX_PACKAGE_NAME, MSIX_PACKAGE_PUBLISHER);
|
|
VersionHelper current_version(VERSION_MAJOR, VERSION_MINOR, VERSION_REVISION);
|
|
|
|
for (auto package : packages)
|
|
{
|
|
VersionHelper msix_version(package.Id().Version().Major, package.Id().Version().Minor, package.Id().Version().Revision);
|
|
|
|
if (msix_version < current_version)
|
|
{
|
|
co_await package_manager.RemovePackageAsync(package.Id().FullName());
|
|
co_return true;
|
|
}
|
|
}
|
|
}
|
|
catch (...)
|
|
{
|
|
}
|
|
co_return false;
|
|
}
|
|
} |