mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-08 20:27:36 +02:00
[installer] Support per-user installation (#24087)
* Add per user installer
* Separate upgrade codes for per machine and per user installation
Move per machine check to bootstrapper
Move all defines to common.wxs
Fix CI
* Update installer/PowerToysSetup/generateFileList.ps1
Co-authored-by: Jeremy Sinclair <4016293+snickler@users.noreply.github.com>
* Update installer/PowerToysSetup/generateAllFileComponents.ps1
Co-authored-by: Jeremy Sinclair <4016293+snickler@users.noreply.github.com>
* Update installer/PowerToysSetup/generateFileList.ps1
Co-authored-by: Jeremy Sinclair <4016293+snickler@users.noreply.github.com>
* expect.txt
* Revert "Update installer/PowerToysSetup/generateFileList.ps1"
This reverts commit 34545dab9c.
* Update release CI to build both installers
* Revert bundle name change
It messes up app ID for per-user installation which ends up breaking winget update
of the per-user PT
* spellcheck
* Fix bad merge
* Add RegistryPreview
* Include backup_restore_settings.json
* Revert testing endpoint change
---------
Co-authored-by: Jeremy Sinclair <4016293+snickler@users.noreply.github.com>
This commit is contained in:
@@ -16,6 +16,83 @@
|
||||
|
||||
namespace registry
|
||||
{
|
||||
namespace install_scope
|
||||
{
|
||||
const wchar_t INSTALL_SCOPE_REG_KEY[] = L"Software\\Classes\\powertoys\\";
|
||||
|
||||
enum class InstallScope
|
||||
{
|
||||
PerMachine = 0,
|
||||
PerUser,
|
||||
};
|
||||
|
||||
inline const InstallScope get_current_install_scope()
|
||||
{
|
||||
// Open HKLM key
|
||||
HKEY perMachineKey{};
|
||||
if (RegOpenKeyExW(HKEY_LOCAL_MACHINE,
|
||||
INSTALL_SCOPE_REG_KEY,
|
||||
0,
|
||||
KEY_READ,
|
||||
&perMachineKey) != ERROR_SUCCESS)
|
||||
{
|
||||
// Open HKCU key
|
||||
HKEY perUserKey{};
|
||||
if (RegOpenKeyExW(HKEY_CURRENT_USER,
|
||||
INSTALL_SCOPE_REG_KEY,
|
||||
0,
|
||||
KEY_READ,
|
||||
&perUserKey) != ERROR_SUCCESS)
|
||||
{
|
||||
// both keys are missing
|
||||
return InstallScope::PerMachine;
|
||||
}
|
||||
else
|
||||
{
|
||||
DWORD dataSize{};
|
||||
if (RegGetValueW(
|
||||
perUserKey,
|
||||
nullptr,
|
||||
L"InstallScope",
|
||||
RRF_RT_REG_SZ,
|
||||
nullptr,
|
||||
nullptr,
|
||||
&dataSize) != ERROR_SUCCESS)
|
||||
{
|
||||
// HKCU key is missing
|
||||
RegCloseKey(perUserKey);
|
||||
return InstallScope::PerMachine;
|
||||
}
|
||||
|
||||
std::wstring data;
|
||||
data.resize(dataSize / sizeof(wchar_t));
|
||||
|
||||
if (RegGetValueW(
|
||||
perUserKey,
|
||||
nullptr,
|
||||
L"InstallScope",
|
||||
RRF_RT_REG_SZ,
|
||||
nullptr,
|
||||
&data[0],
|
||||
&dataSize) != ERROR_SUCCESS)
|
||||
{
|
||||
// HKCU key is missing
|
||||
RegCloseKey(perUserKey);
|
||||
return InstallScope::PerMachine;
|
||||
}
|
||||
RegCloseKey(perUserKey);
|
||||
|
||||
if (data.contains(L"perUser"))
|
||||
{
|
||||
return InstallScope::PerUser;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return InstallScope::PerMachine;
|
||||
}
|
||||
}
|
||||
|
||||
template<class>
|
||||
inline constexpr bool always_false_v = false;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user