diff --git a/src/common/common.vcxproj b/src/common/common.vcxproj
index b997432e7..5e41a1ffc 100644
--- a/src/common/common.vcxproj
+++ b/src/common/common.vcxproj
@@ -125,6 +125,7 @@
+
@@ -159,6 +160,7 @@
+
Create
diff --git a/src/common/common.vcxproj.filters b/src/common/common.vcxproj.filters
index 2a255a8c9..69899feaa 100644
--- a/src/common/common.vcxproj.filters
+++ b/src/common/common.vcxproj.filters
@@ -111,6 +111,9 @@
Header Files
+
+ Header Files
+
Header Files
@@ -183,6 +186,9 @@
Source Files
+
+ Source Files
+
Source Files
diff --git a/src/modules/launcher/Microsoft.Launcher/dllmain.cpp b/src/modules/launcher/Microsoft.Launcher/dllmain.cpp
index 479655cf2..3a4c714f6 100644
--- a/src/modules/launcher/Microsoft.Launcher/dllmain.cpp
+++ b/src/modules/launcher/Microsoft.Launcher/dllmain.cpp
@@ -6,6 +6,7 @@
#include
#include "trace.h"
#include "resource.h"
+#include
extern "C" IMAGE_DOS_HEADER __ImageBase;
@@ -132,60 +133,64 @@ public:
// Enable the powertoy
virtual void enable()
{
- unsigned long powertoys_pid = GetCurrentProcessId();
-
- if (!is_process_elevated(false))
+ // Start PowerLauncher.exe only if the OS is 19H1 or higher
+ if (UseNewSettings())
{
- std::wstring executable_args = L"";
- executable_args.append(std::to_wstring(powertoys_pid));
+ unsigned long powertoys_pid = GetCurrentProcessId();
- SHELLEXECUTEINFOW sei{ sizeof(sei) };
- sei.fMask = { SEE_MASK_NOCLOSEPROCESS | SEE_MASK_FLAG_NO_UI };
- sei.lpFile = L"modules\\launcher\\PowerLauncher.exe";
- sei.nShow = SW_SHOWNORMAL;
- sei.lpParameters = executable_args.data();
- ShellExecuteExW(&sei);
-
- m_hProcess = sei.hProcess;
- }
- else
- {
- std::wstring action_runner_path = get_module_folderpath();
-
- std::wstring params;
- params += L"-run-non-elevated ";
- params += L"-target modules\\launcher\\PowerLauncher.exe ";
- params += L"-pidFile ";
- params += POWER_LAUNCHER_PID_SHARED_FILE;
- params += L" " + std::to_wstring(powertoys_pid) + L" ";
-
- action_runner_path += L"\\action_runner.exe";
- // Set up the shared file from which to retrieve the PID of PowerLauncher
- HANDLE hMapFile = CreateFileMappingW(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, sizeof(DWORD), POWER_LAUNCHER_PID_SHARED_FILE);
- if (hMapFile)
+ if (!is_process_elevated(false))
{
- PDWORD pidBuffer = reinterpret_cast(MapViewOfFile(hMapFile, FILE_MAP_ALL_ACCESS, 0, 0, sizeof(DWORD)));
- if (pidBuffer)
- {
- *pidBuffer = 0;
- m_hProcess = NULL;
+ std::wstring executable_args = L"";
+ executable_args.append(std::to_wstring(powertoys_pid));
- if (run_non_elevated(action_runner_path, params, pidBuffer))
+ SHELLEXECUTEINFOW sei{ sizeof(sei) };
+ sei.fMask = { SEE_MASK_NOCLOSEPROCESS | SEE_MASK_FLAG_NO_UI };
+ sei.lpFile = L"modules\\launcher\\PowerLauncher.exe";
+ sei.nShow = SW_SHOWNORMAL;
+ sei.lpParameters = executable_args.data();
+ ShellExecuteExW(&sei);
+
+ m_hProcess = sei.hProcess;
+ }
+ else
+ {
+ std::wstring action_runner_path = get_module_folderpath();
+
+ std::wstring params;
+ params += L"-run-non-elevated ";
+ params += L"-target modules\\launcher\\PowerLauncher.exe ";
+ params += L"-pidFile ";
+ params += POWER_LAUNCHER_PID_SHARED_FILE;
+ params += L" " + std::to_wstring(powertoys_pid) + L" ";
+
+ action_runner_path += L"\\action_runner.exe";
+ // Set up the shared file from which to retrieve the PID of PowerLauncher
+ HANDLE hMapFile = CreateFileMappingW(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, sizeof(DWORD), POWER_LAUNCHER_PID_SHARED_FILE);
+ if (hMapFile)
+ {
+ PDWORD pidBuffer = reinterpret_cast(MapViewOfFile(hMapFile, FILE_MAP_ALL_ACCESS, 0, 0, sizeof(DWORD)));
+ if (pidBuffer)
{
- const int maxRetries = 80;
- for (int retry = 0; retry < maxRetries; ++retry)
+ *pidBuffer = 0;
+ m_hProcess = NULL;
+
+ if (run_non_elevated(action_runner_path, params, pidBuffer))
{
- Sleep(50);
- DWORD pid = *pidBuffer;
- if (pid)
+ const int maxRetries = 80;
+ for (int retry = 0; retry < maxRetries; ++retry)
{
- m_hProcess = OpenProcess(PROCESS_TERMINATE, FALSE, pid);
- break;
+ Sleep(50);
+ DWORD pid = *pidBuffer;
+ if (pid)
+ {
+ m_hProcess = OpenProcess(PROCESS_TERMINATE, FALSE, pid);
+ break;
+ }
}
}
}
+ CloseHandle(hMapFile);
}
- CloseHandle(hMapFile);
}
}
diff --git a/src/runner/runner.vcxproj b/src/runner/runner.vcxproj
index da994d9a1..bfea3a909 100644
--- a/src/runner/runner.vcxproj
+++ b/src/runner/runner.vcxproj
@@ -238,9 +238,6 @@
{74485049-c722-400f-abe5-86ac52d929b3}
-
- {e6410bfc-b341-498c-8c67-312c20cdd8d5}
-
{17da04df-e393-4397-9cf0-84dabe11032e}
diff --git a/src/runner/settings_window.cpp b/src/runner/settings_window.cpp
index f0afac1af..918796d48 100644
--- a/src/runner/settings_window.cpp
+++ b/src/runner/settings_window.cpp
@@ -14,7 +14,7 @@
#include
#include
-#include
+#include
#define BUFSIZE 1024